PHP Class ApiPlatform\Core\Action\ExceptionAction
Usage:
$exceptionAction = new ExceptionAction(
new Serializer(),
[
'jsonproblem' => ['application/problem+json'],
'jsonld' => ['application/ld+json'],
],
[
ExceptionInterface::class => Response::HTTP_BAD_REQUEST,
InvalidArgumentException::class => Response::HTTP_BAD_REQUEST,
]
);
Show file
Open project: api-platform/core
Public Methods
Method |
Description |
|
__construct ( Symfony\Component\Serializer\SerializerInterface $serializer, array $errorFormats, array $exceptionToStatus = [] ) |
|
|
__invoke ( FlattenException $exception, Request $request ) : Response |
Converts a an exception to a JSON response. |
|
Method Details
__construct()
public method
public __construct ( Symfony\Component\Serializer\SerializerInterface $serializer, array $errorFormats, array $exceptionToStatus = [] ) |
$serializer |
Symfony\Component\Serializer\SerializerInterface |
|
$errorFormats |
array |
A list of enabled formats, the first one will be the default |
$exceptionToStatus |
array |
A list of exceptions mapped to their HTTP status code |
Converts a an exception to a JSON response.
public __invoke ( FlattenException $exception, Request $request ) : Response |
$exception |
Symfony\Component\Debug\Exception\FlattenException |
|
$request |
Symfony\Component\HttpFoundation\Request |
|
return |
Symfony\Component\HttpFoundation\Response |
|