We solved this by introducing a Result library.
load("@.../result", result=result) def throw(arg): return 1/0 if result.Result(throw).map(arg).is_ok: # proceed else: fail("...")