Open ARawles opened 3 years ago
I just stumbled upon this confusing behavior. An ideal setup would be to have the error handler in the base router handle any unhandled errors in any of it's mounted routers.
With the current implementation, if you are trying to compose a complex API and mounting several routers, then you have to put the error handlers in each mounted child router instead of just being able to set it once in the base router.
As displayed in this example:
The error raised in the base "/error" endpoint is passed to the error handler set via
pr_set_error()
, but the error raised in the mounted router via the "/mounted/error" isn't.Is this the expected behaviour? I appreciate that this does allow different mounted routers to use different error handling functions, but also introduces some duplication when you want to use the same one. Could the mounted routers perhaps inherit their error path from the parent with the opportunity to set more specific error handlers like so: