Download the PHP package hamidreza2005/laravel-api-error-handler without Composer
On this page you can find all versions of the php package hamidreza2005/laravel-api-error-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hamidreza2005/laravel-api-error-handler
More information about hamidreza2005/laravel-api-error-handler
Files in hamidreza2005/laravel-api-error-handler
Package laravel-api-error-handler
Short Description a package for handle api errors
License MIT
Informations about the package laravel-api-error-handler
Laravel Api Error Handler
a useful package for handling exception in laravel.
:inbox_tray: Installation
you can install this package via Composer:
and after installation you can run following command to publish config files
:gear: Configuration
to configure this package go to config/api-error-handler.php
this package provides some handlers for common exceptions like ModelNotFound
But if you want to customize it you can do like this :
Class | Status Code | Message |
---|---|---|
NotFoundException | 404 | Not Found |
ServerInternalException | 500 | Server Internal Error |
AccessDeniedException | 403 | Access Denied |
ValidationException | 422 | all validation errors |
DefaultException | the status code of the Exception | the message of the Exception |
:rocket: how to let handlers do their job ?
add ApiErrorHandler
trait to ExceptionHandler
located in app\Exceptions\Handler.php
:
Make Your Own Exception Handler!
if you want to make your own handler your class has to extend hamidreza2005\LaravelApiErrorHandler\Handlers\ExceptionHandler
i.e:
:scroll: License
The MIT License (MIT). Please see License File for more information.
:raising_hand: Contributing
If you find an issue, or have a better way to do something, feel free to open an issue , or a pull request.