Skip to content

frovere/JsonException

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Json Exception formatter.

Example.

    public function render($request, Exception $exception)
    {
        if($request->wantsJson()) {
            $response = JsonExceptionFactory::make($exception);
            return new JsonResponse($response->getBodyResponse(), $response->getStatus());
        }
        return parent::render($request, $exception);
    }

Customize.

You can define a custom transformer to exceptions on the config file json-exceptions.php transformer must extends \Cesg\JsonException\JsonExceptionAbstract

return [
    'handlers' => [
        \App\Exceptions\CustomException::class => \App\Exceptions\CustomExceptionTransformer::class,
    ],
];

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%