Skip to content

Commit cf25f58

Browse files
authored
docs(errors): warn that exception_to_status is not merged with defaults (#2291)
Closes #6116
1 parent 7150703 commit cf25f58

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

core/errors.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ return [
164164
];
165165
```
166166

167+
> [!WARNING] The `exception_to_status` configuration is **not merged** with the defaults: as soon as
168+
> you declare your own mapping, it replaces the built-in one entirely. If you omit the default
169+
> handlers shown above, exceptions that were previously mapped to `400` (such as the
170+
> `Symfony\Component\Serializer\Exception\ExceptionInterface` thrown when denormalizing a relation
171+
> to a non-existing item, or an invalid backed enum value) will fall through to the `500` fallback.
172+
> Always keep the default lines and append your custom mappings to them.
173+
167174
Any type of `Exception` can be thrown, API Platform will convert it to a Symfony's `HttpException`
168175
(note that it means the exception will be flattened and lose all of its custom properties). The
169176
framework also takes care of serializing the error description according to the request format. For

0 commit comments

Comments
 (0)