3 ms·
what about this pattern? https://www.inngest.com/blog/python-errors-as-values https://www.inngest.com/blog/python-errors-as-values I tried it once in an sqlite
by meehai 2y ago
what about this pattern?
https://www.inngest.com/blog/python-errors-as-values https://www.inngest.com/blog/python-errors-as-values
I tried it once in an sqlite DB connector with some business logic and simply checking stuff like
res: DBException | Result = db_handler.some_business_logic()
if isinstance(res, DBException):
return res # you can also log or even raise if this function isn't returning exceptions as values
# guaranteed to be Result type here
See here:
- https://gitlab.com/meehai/drpciv-flask/-/blob/main/be/db_handler.py?ref_type=heads#L186 https://gitlab.com/meehai/drpciv-flask/-/blob/main/be/db_han...
- https://gitlab.com/meehai/drpciv-flask/-/blob/main/be/app.py?ref_type=heads#L69 https://gitlab.com/meehai/drpciv-flask/-/blob/main/be/app.py...