Download the PHP package senkevich33n/laravel-api-error-handler without Composer
On this page you can find all versions of the php package senkevich33n/laravel-api-error-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download senkevich33n/laravel-api-error-handler
More information about senkevich33n/laravel-api-error-handler
Files in senkevich33n/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 handle your exception when you are developing a API
:inbox_tray: Installation
you can install this package via Composer:
and after installation you can run following command to publish config files
:gear: Configuration
for configure this package go to config/api-error-handler.php
this package provide some common exception 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 | it returns all errors in validation |
DefaultException | the status code of the Error | the message of the Error |
:rocket: let this package get your Errors
go to the app\Exceptions\Handler.php
and put this code:
Make Your Own Error Handler!
if you want to make your own handler instead of using default handler you can make a class in everywhere you want but your class have to Extends hamidreza2005\LaravelApiErrorHandler\Exceptions\ExceptionAbstract
for Example:
and you can do like this in config/api-error-handler.php
:
❗ Notice
if an unknown Exception appeared this package automaticlly show it in the response but if you don't want that you can set APP_DEBUG
to false
in .env
. when APP_DEBUG
is false
Server Internal shown in response
: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.