Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson authored Jan 22, 2022
1 parent 3ff21f2 commit 7798ddd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,28 @@ results in:
}
```

## Use with the Exception Handler

```php
namespace App\Exceptions;

use ApiSkeletons\Laravel\ApiProblem\Facades\ApiProblem;
use Doctrine\ORM\EntityNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Request;

class Handler extends ExceptionHandler
{
public function register(): void
{
$this->renderable(function (EntityNotFoundException $e, Request $request) {
return ApiProblem::response($e->getMessage(), 404);
});
}
}

```

## Attribution

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

0 comments on commit 7798ddd

Please sign in to comment.