Skip to content
Merged
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
3 changes: 3 additions & 0 deletions core/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ api_platform:
ApiPlatform\Core\Exception\FilterValidationException: 400
Doctrine\ORM\OptimisticLockException: 409

# Validation exception
ApiPlatform\Core\Bridge\Symfony\Validator\Exception\ValidationException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_UNPROCESSABLE_ENTITY

# Custom mapping
App\Exception\ProductNotFoundException: 404 # Here is the handler for our custom exception
```
Expand Down
2 changes: 1 addition & 1 deletion core/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ It's because a built-in [custom exception normalizer](#custom-exception-normaliz
If you are in `dev` mode, more entries will be added in the response: `debugMessage` (containing the actual exception message, for instance in the case of a `LogicException`) and `trace` (the formatted exception trace).

For some specific exceptions, built-in [custom exception normalizers](#custom-exception-normalizer) are also used to add more information.
It's the case for a `HttpException` for which the `status` entry will be added under `extensions` and for a `ValidationException` for which `status` (always 400) and `violations` entries will be added.
It's the case for a `HttpException` for which the `status` entry will be added under `extensions` and for a `ValidationException` for which `status` (by default 422) and `violations` entries will be added.

#### Custom Exception Normalizer

Expand Down
2 changes: 1 addition & 1 deletion core/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ final class MinimalPropertiesValidator extends ConstraintValidator
}
```

If the data submitted by the client is invalid, the HTTP status code will be set to `400 Bad Request` and the response's
If the data submitted by the client is invalid, the HTTP status code will be set to `422 Unprocessable Entity` and the response's
body will contain the list of violations serialized in a format compliant with the requested one. For instance, a validation
error will look like the following if the requested format is JSON-LD (the default):

Expand Down
2 changes: 1 addition & 1 deletion distribution/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class BooksTest extends ApiTestCase
'isbn' => 'invalid',
]]);

$this->assertResponseStatusCodeSame(400);
$this->assertResponseStatusCodeSame(422);
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');

$this->assertJsonContains([
Expand Down