  We study the largest possible length $B$ of $(B-1)$-dimensional linear codes
over $\mathbb{F}_q$ which can correct up to $t$ errors taken from a restricted
set $\mathcal{A}\subseteq \mathbb{F}_q^*$. Such codes can be applied to
multilevel flash memories.
  Moreover, in the case that $q=p$ is a prime and the errors are limited by a
constant we show that often the primitive $\ell$th roots of unity, where $\ell$
is a prime divisor of $p-1$, define good such codes.
