File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff 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
129151The bulk of this repository was copied from Laminas API Tools. I wanted to provide a
You can’t perform that action at this time.
0 commit comments