| 1 | <?php |
||
| 25 | class ExceptionNormalizer extends AbstractExceptionNormalizer implements NormalizerInterface |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * {@inheritdoc} |
||
| 29 | */ |
||
| 30 | public function normalize($object, $format = null, array $context = []): array |
||
| 31 | { |
||
| 32 | $data = []; |
||
| 33 | |||
| 34 | if (isset($context['status_code'])) { |
||
| 35 | $data['code'] = $statusCode = $context['status_code']; |
||
| 36 | } |
||
| 37 | |||
| 38 | $data['message'] = $this->getMessageFromThrowable($object, isset($statusCode) ? $statusCode : null); |
||
| 39 | |||
| 40 | return $data; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | 7 | public function supportsNormalization($data, $format = null): bool |
|
| 50 | } |
||
| 51 |
If you suppress an error, we recommend checking for the error condition explicitly: