Allow to set a custom error handler in router configuration.#21
Allow to set a custom error handler in router configuration.#21Madeorsk wants to merge 1 commit intotardy-org:mainfrom
Conversation
|
I will take a look at this later today or tomorrow. I'm curious on if you were still planning on building out support for middleware? If yes, are you planning on keeping the error handler like this or doing a layered style? |
|
I've implemented middlewares on my development branch, and didn't change how this error handling was made because I wanted to keep a "top-level" error handler which can catch request parsing errors. For "route specific" (or "routes group specific") error handling, middlewares will be required (and will allow to do that). But my doubts were more about the not found handler. I think that "not found" is just a specific error that could be added to |
+ Add an option for a custom error handler and set a complete default one. * Change handler context to allow its initialization without a matched route. * Alphabetical order of HTTPError errors.
c165662 to
d8a593a
Compare
|
I rebased my branch on the current |
Hi! This pull request provides something like
not_found_handlerbut for errors. It also generalizes error response sending inServer: everything now go through the newhandle_errorwhich tries to call the error handler, and responds internal server error if the error handler fails. To generalize these calls and the implementation of the handler, I needed to initialize a context instance even before request parsing. This should be taken in account when implementing an error handler, as the request may not be completely initialized if an error happened while parsing it.