Skip to content

Commit 7798ddd

Browse files
authored
Update README.md
1 parent 3ff21f2 commit 7798ddd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: README.md

+22
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,28 @@ results in:
124124
}
125125
```
126126

127+
## Use with the Exception Handler
128+
129+
```php
130+
namespace App\Exceptions;
131+
132+
use ApiSkeletons\Laravel\ApiProblem\Facades\ApiProblem;
133+
use Doctrine\ORM\EntityNotFoundException;
134+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
135+
use Illuminate\Http\Request;
136+
137+
class Handler extends ExceptionHandler
138+
{
139+
public function register(): void
140+
{
141+
$this->renderable(function (EntityNotFoundException $e, Request $request) {
142+
return ApiProblem::response($e->getMessage(), 404);
143+
});
144+
}
145+
}
146+
147+
```
148+
127149
## Attribution
128150

129151
The bulk of this repository was copied from Laminas API Tools. I wanted to provide a

0 commit comments

Comments
 (0)