diff --git a/.docs/errors.md b/.docs/errors.md index bdf5e5a..ae2bc95 100644 --- a/.docs/errors.md +++ b/.docs/errors.md @@ -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 diff --git a/.docs/index.md b/.docs/index.md index bf7a34d..c50e8c6 100644 --- a/.docs/index.md +++ b/.docs/index.md @@ -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. diff --git a/.docs/middlewares.md b/.docs/middlewares.md index 52b2581..049d374 100644 --- a/.docs/middlewares.md +++ b/.docs/middlewares.md @@ -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)