| Package Data | |
|---|---|
| Maintainer Username: | whoan |
| Maintainer Contact: | juaneabadie@gmail.com (Juan Eugenio Abadie) |
| Package Create Date: | 2016-12-13 |
| Package Last Update: | 2017-01-19 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-11 03:07:09 |
| Package Statistics | |
|---|---|
| Total Downloads: | 385 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 0 |
| Total Watchers: | 2 |
| Total Forks: | 1 |
| Total Open Issues: | 0 |
Convert your Lumen exceptions into JSON:
{
"code": nnn,
"message": "a message",
"description": "a description",
"errors": [
"error 1",
"error 2",
...
]
}
Set your composer.json to allow less stable packages:
"minimum-stability" : "dev",
"prefer-stable" : true
Require the package as usual:
composer require nextdots/api-exceptions
Change app/Exceptions/Handler.php:
Change this:
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
To this:
use ApiExceptions\Handler as ExceptionHandler;
On Linux, you can do the same as above with the following command:
sed -i 's/Laravel\\Lumen\\Exceptions\\Handler/ApiExceptions\\Handler/' app/Exceptions/Handler.php
use ApiExceptions\JsonResponseException;
$app->get('/throw-exception', function () {
throw new JsonResponseException(400, "an exception", "a description");
});