Skip to content

Commit 95cb1b6

Browse files
author
Samuel
committed
Added instructions how to registry new handlers
1 parent e15752e commit 95cb1b6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,27 @@ class MyCustomizedHandler extends AbstractHandler
272272
}
273273
```
274274

275+
- Now just registry your customized handler on `App\Exception\Handler` file on attribute `exceptionHandlers`. E.g:
276+
277+
```php
278+
namespace App\Exceptions;
279+
280+
use Exception;
281+
use GuzzleHttp\Exception\ClientException;
282+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
283+
use SMartins\Exceptions\JsonHandler;
284+
285+
class Handler extends ExceptionHandler
286+
{
287+
use JsonHandler;
288+
289+
protected $exceptionHandlers = [
290+
// Set on key the exception and on value the handler.
291+
ClientException::class => GuzzleClientHandler::class,
292+
];
293+
294+
```
295+
275296
## Response References:
276297

277298
- http://jsonapi.org/format/#errors

0 commit comments

Comments
 (0)