tasking-manager
tasking-manager copied to clipboard
Improve error handling on backend
Is your feature request related to a problem? Please describe. After the introduction of error subcode on #5039, the error handling on the backend is quite messed up.
Describe the solution you'd like
To fix this issue we can use the custom error handling method defined on https://github.com/flask-restful/flask-restful/issues/221 instead of using try: except:
everywhere to handle errors.
Describe alternatives you've considered There is an issue in #2951 to replace flask restful library as it's no longer maintained, so maybe we can think of replacing flask restful with Flask itself or with FastAPI as mentioned in #2283.
I would like to solve this issue. Kindly assign this task to me.
@joanjeremiah feel free to work on this.
@tsmock can you take a look here and provide the team some feedback on this error handling scheme under proposal?
My first response is "LGTM". I spent quite a bit of time tracking down errors when the stack traces weren't being printed, and it looks like #5899 will help fix that once they move over to the specific exceptions.
Beyond that:
- I like that they are using a single base class for all TM exceptions (makes it easy to "catch" if we really need to)
- Not really certain about loading error messages in
__init__.py
-- I would be surprised if it was loaded multiple times if the error messages were loaded inexceptions.py
. I'd have to run it through a debugger though.