Catches exceptions that occur during request handling and output them as JSON.
- PHP >= 7.2
- A PSR-7 http message implementation (Diactoros, Guzzle, Slim, etc...)
- A PSR-15 middleware dispatcher
This package is installable and autoloadable via Composer as middlewares/json-exception-handler.
composer require middlewares/json-exception-handlerCatches exceptions thrown that occur later in request processing an creates a new response with HTTP 500 status and JSON encoded version of the exception as the body.
Change the Content-Type header of the response. Default is application/json.
Enable or disable the stack trace in the response. Default is true.
Set options for json_encode of the exception. Default is 0.
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.