Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,11 @@ default values:
```php
<?php
// config/api-platform.php
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\UrlGeneratorInterface;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException;
use Symfony\Component\Serializer\Exception\ExceptionInterface as SerializerExceptionInterface;

return [
// The title of the API.
Expand Down Expand Up @@ -648,7 +650,9 @@ return [
// The list of exceptions mapped to their HTTP status code.
'exception_to_status' => [
AuthenticationException::class => 401,
AuthorizationException::class => 403
AuthorizationException::class => 403,
SerializerExceptionInterface::class => 400,
InvalidArgumentException::class => 400,
],

// The list of routes.
Expand Down
2 changes: 2 additions & 0 deletions core/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ And like this, if you are using API Platform with Laravel:
4. Similarly, check for `App\Contracts\Exceptions\HttpExceptionInterface`.
5. Use defaults for the following exceptions:
- `Illuminate\Http\Exceptions\HttpResponseException` => 400
- `Symfony\Component\Serializer\Exception\ExceptionInterface` => 400
- `ApiPlatform\Metadata\Exception\InvalidArgumentException` => 400
- `ApiPlatform\Symfony\Validator\Exception\ValidationException` => 422
6. The status defined on an `ErrorResource`
7. Fallback to 500.
Expand Down
Loading