Open SoTeKie opened 3 years ago
If I'm correct about my assumption I think the TryCatchMiddleware should be removed and the documentation updated.
Hi. Thx for question. I think it depends on how you're setup chain of middlewares, you can build your own chain and there will be a place for TryCatchMiddleware.
From what I understand TryCatchMiddleware will still catch an exception in other middleware, but not ones thrown in the controller for example. I'm not sure if this is intended but this is the behavior I could replicate so far, maybe it would be a good idea to emphasize that it won't handle errors thrown in controllers. The documentation now is worded in a way that makes it seem like it's the place to handle exceptions in any part of the application.
You're right @SoTeKie, TryCatchMiddleware will catch exceptions throwed in other middleware, generally every other exceptions then in dispatcher.
I would love to see PR with correct wording as you said.
Correct me if I'm wrong as I'm new to apitte and nette in general, but from testing and what I can see, this commit makes the TryCatchMiddleware redundant as it eats up any exceptions that would go the TryCatchMiddleware before this change. I'd appreciate some input even if I'm wrong about this as I'm failing to understand or replicate how TryCatchMiddleware can catch any exceptions with this change.