Skip to content

Commit

Permalink
Add HTTP exception usage (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Jul 29, 2024
1 parent 7ef43b1 commit a6af3bb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/v4/middleware/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,15 @@ class HttpGatewayTimeoutException extends HttpSpecializedException
protected $description = 'Timed out before receiving response from the upstream server.';
}
```

To throw HTTP exceptions, use the following code:

```php
use Slim\Exception\HttpNotFoundException;
// ...

throw new HttpNotFoundException($request);
```

Ensure you pass the `$request` object when throwing the exception.

0 comments on commit a6af3bb

Please sign in to comment.