Hacker News new | ask | show | jobs
by meehai 621 days ago
what about this pattern? 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_han...

- https://gitlab.com/meehai/drpciv-flask/-/blob/main/be/app.py...