diff --git a/packages/mango/Serializer/MoneyNormalizer.php b/packages/mango/Serializer/MoneyNormalizer.php index cca97c7..dd866d2 100644 --- a/packages/mango/Serializer/MoneyNormalizer.php +++ b/packages/mango/Serializer/MoneyNormalizer.php @@ -4,7 +4,7 @@ namespace Manyou\Mango\Serializer; -use Error; +use ErrorException; use Money\Currency; use Money\Money; use Symfony\Component\Serializer\Exception\NotNormalizableValueException; @@ -21,8 +21,8 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a try { return new Money($data['amount'], new Currency($data['currency'])); - } catch (Error $e) { - throw new NotNormalizableValueException($e->getMessage(), $e->getCode(), $e); + } catch (ErrorException $e) { + throw NotNormalizableValueException::createForUnexpectedDataType($e->getMessage(), $data, ['{amount: int|string, currency: string}']); } }