egeatech/laravel-exceptions

A simple package to better handle Exceptions.

3.0.1 2024-01-09 16:30 UTC

README

Latest Version on Packagist Total Downloads

A package to help handling exceptions which may occur in your application.

Installation

This package supports Laravel 7, 8 and 9 but requires at least PHP 8.0 starting from v2.x. PHP 7.4 is supported up to version 1.3.0.

Via Composer

$ composer require egeatech/laravel-exceptions

Usage

During the implementation of the business logic of your application, if you wish to throw an exception simply create a new class extending EgeaTech\LaravelExceptions\Exceptions\ApplicationException.

After that, create a new translation file inside your [resources/]lang/en/exceptions folder: the file must be the snake case version of the exception class name. Keep in mind that at least the English form is required.

Now that we're all set, the base exception class will take care of logging the exception in English given its translation key, leaving to the user the choice to return a translated version of the error to the client or, otherwise, return only the exception key for further processes or custom error messages to be displayed.

Change log

Please see the CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

The software is licensed under MIT. Please see the LICENSE file for more information.