https://github.com/pt-dot/laravel-error-message
Laravel simple error message display from exception
https://github.com/pt-dot/laravel-error-message
exception-reporting laravel package php
Last synced: about 1 month ago
JSON representation
Laravel simple error message display from exception
- Host: GitHub
- URL: https://github.com/pt-dot/laravel-error-message
- Owner: pt-dot
- License: mit
- Created: 2019-05-21T06:16:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-01T05:08:35.000Z (over 6 years ago)
- Last Synced: 2025-12-11T19:30:25.073Z (6 months ago)
- Topics: exception-reporting, laravel, package, php
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Error Message Displayer
Sometimes in development mode, you want to display exception message to know what happened to your web application. But in production environment, you may want to display general message instead of direct exception message. Laravel error message displayer is a package for displaying exception message or trace string based on `APP_DEBUG` condition.
## Requirements
+ php 7.0+
+ Laravel 5.5+
## Installation
Install package through composer.
```bash
composer require ptdot/errormessage
```
Next, if using Laravel under 5.5, include the service provider and Facade within your `config/app.php` file.
```php
'providers' => [
Ptdot\ErrorMessage\ErrorMessageServiceProvider::class,
],
'aliases' => [
'ErrorMessage' => Ptdot\ErrorMessage\ErrorMessage::class,
]
```
Since Laravel 5.5+ is using Package Discovery, there is no need manually insert service provider and facade inside your `app.php`.
## Configuration
Publish config using command:
```bash
php artisan vendor:publish
```
Set your default error message in `config/errormessage.php`.
## Basic Usage
You may use this package to handle exception display through your REST API or flash message.
```php
json([
'errors' => ErrorMessage::displayExceptionMessage($exception)
], 500);
}
```
If you want to debug and need display `traceAsString` option, you may call `traceAsString()` method:
```php
// you may need traceAsString option enabled using this way:
return response()->json([
'errors' => ErrorMessage::traceAsString()->displayExceptionMessage($exception)
], 500);
```
Want to override default message? Don't worry this package is able to do that.
```php
// Need to override exception message? Don't worry
return response()->json([
'errors' => ErrorMessage::displayExceptionMessage($exception, 'exception message will be overrided with this')
], 500);
```
## Contributing
Feel free to report an issue or merge request if you want to help this package become better and useful.