Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Default error handler

- Transforms error into json response
- ApiException (and inherited errors like ClientErrorException) message, context and code are used directly in response
- For other (non-api) errors is used generic message described bellow
- For other (non-api) errors is used generic message described below
- Context is send only if is not empty

```json
Expand Down
2 changes: 1 addition & 1 deletion .docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ if ($isApi) {
- Console plugin
- Console commands for your api.
- Based on [symfony/console](https://github.com/symfony/console)
- See [console](console.md) chpater for more info.
- See [console](console.md) chapter for more info.
- Presenter plugin
- Route into your api through a single nette route and presenter.
- See [presenter](presenter.md) chapter for more info.
Expand Down
16 changes: 15 additions & 1 deletion .docs/middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,18 @@ class ExampleMiddleware implements IMiddleware
}
```

See [contributte/middlewares](https://github.com/contributte/middlewares) documentation for more info and useful middlewares
See [contributte/middlewares](https://github.com/contributte/middlewares) documentation for more info and useful middlewares.

## Exception Handling

**Important note about `TryCatchMiddleware`:**

If you use `TryCatchMiddleware` from [contributte/middlewares](https://github.com/contributte/middlewares), be aware that it only catches exceptions thrown in **other middleware**, not exceptions thrown in controllers.

Exceptions thrown during controller execution are handled internally by `ApiMiddleware`, which wraps the dispatcher call in its own try-catch block. This means:

- `TryCatchMiddleware` catches exceptions from middleware running before or after `ApiMiddleware`
- `ApiMiddleware` catches and handles exceptions from the dispatcher (controller execution)
- Controller exceptions are processed by the internal [error handler](errors.md) or [exception decorators](decorators.md#exception-decorators)

If you need custom exception handling for controller errors, use [exception decorators](decorators.md#exception-decorators) or implement a custom [error handler](errors.md#error-handler)
Loading