Uncaught Error: Class "LabelSheet\UnexpectedValueException" not found
Bonjour,
Je ne comprends pas le message d'erreur Uncaught Error: Class "LabelSheet\UnexpectedValueException" not found
à la ligne 21 et je ne vois pas où est l'erreur. Qu'est-ce qui n'est pas trouvé?
Ici, je fais le test avec -2 en argument du constructeur.
La ligne 17 (var_dump) renvoie 'Invalid argument supplied in 'LabelSheet\LabelSheet::__construct'. First parameter must be an integer between 0 and 8.'
Je m'attendais à trouver le texte du var_dump dans le message d'erreur.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| namespace LabelSheet;
use Exception;
class LabelSheet
{
const INVALID_ARG = "Invalid argument supplied in '%s'. ";
public function __construct(int|array $inData)
{
if (is_int($inData))
{
$first = array_key_first(self::INTERN_TEMPLATES);
$last = array_key_last(self::INTERN_TEMPLATES);
if ($inData < $first or $inData > $last)
{
var_dump(sprintf(self::INVALID_ARG, __method__).sprintf(
"First parameter must be an integer between %d and %d.",
$first,
$last));
throw new UnexpectedValueException(sprintf(self::INVALID_ARG, __method__).sprintf(
"First parameter must be an integer between %d and %d.",
$first,
$last));
}
// Suite du code
}
}
} |