Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bohanyang committed Aug 21, 2023
1 parent f44ae4c commit 18f0b6f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/mango/Serializer/MoneyNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Manyou\Mango\Serializer;

use Error;
use ErrorException;
use Money\Currency;
use Money\Money;
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
Expand All @@ -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}']);
}
}

Expand Down

0 comments on commit 18f0b6f

Please sign in to comment.