Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Laravel Errors Handling

Laravel Errors Handling allow you to manage errors codes. Sometimes HTTP status aren't enought. With this package you can create your own status with a short description to share it with your team.


Install the package using composer

composer require saverty/errors_handling

Publish the configuration

php artisan vendor:publish --provider="Saverty\ErrorsHandling\ErrorsHandlingServiceProvider" --tag="config"

Go to your app.php and add the provider


Add your codes

Go to errors_handling.php config file and follow the example. Your codes can be grouped by category. Each code needs a code, a name and a description

return [
    //Group your codes 
    "Authentifcation" => [
        //Detail your code
        "AUTH001" => [
            "name" => "Login Fail",
            "description" => "Email or password is wrong"

Use the package

use Saverty\ErrorsHandling\ErrorsHandling;

Add a code error

$errors = new ErrorsHandling();


Add multiple errors

$errors = new ErrorsHandling();

Group your errors

$errors = new ErrorsHandling();

$errors->add('AUTH001', 'email')->add('AUTH002','email');
$errors->add('AUTH003', 'name')->add('AUTH004','name');

Check if errors are presents

    // No errors

Return errors as an array


Return errors as a Json


Use the laravel validator

 $validator = Validator::make($request->all(),
            "email" => ['required', 'integer'],
            "password" => ['required', 'email']
            "email.integer" => "AUTH001"


Your documentation

You can see the all your codes at this url : {your_domain}/errorshandling

You can’t perform that action at this time.