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, ] );
Author: Baptiste Meyer ([email protected])
Author: Kévin Dunglas ([email protected])
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

__invoke() public method

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