spiral / app

Spiral Framework Skeleton HTTP Application: Queue, Console, Cycle ORM
https://spiral.dev/
MIT License
190 stars 20 forks source link

Exception is not handled by ViewRenderer #95

Closed arizanovj closed 1 year ago

arizanovj commented 1 year ago

When you install the skeleton app and go to http://localhost:8080/exception the exception is not handled by App\Application\Service\ErrorHandler\ViewRenderer instead it displays the raw exception string. image

butschster commented 1 year ago

Hi @arizanovj

Could you try to set DEBUG=false env variable and check?

wolfy-j commented 1 year ago

Maybe we can provide an option to select Yii or Whoops as default error handler?

arizanovj commented 1 year ago

Hi @arizanovj

Could you try to set DEBUG=false env variable and check?

Works this way, but I'll be using the handler to handle validation exceptions and return JSON responses. Is it possible to make it work with DEBUG=true ? My reasoning is that once the handler catches the exception it should not be propagated regardless of the DEBUG value.

butschster commented 1 year ago

Hi @arizanovj! Sorry for long response. Validation exceptions and debug mod are not related.

To handle filter validation exception you can use Spiral\Filter\ValidationHandlerMiddleware and Spiral\Filters\ErrorsRendererInterface

https://spiral.dev/docs/filters-filter/3.5/en#handle-validation-errors

Here https://spiral.dev/docs/http-errors/3.5/en you can read about working with HTTP exceptions

arizanovj commented 1 year ago

Thanks for the explanation.