I think this should be a bit tricky but somehow feasible, but I need help. I'd like to execute two functions from within my main() func. I'd like to be able to catch exceptions from the two separately, but still being able to execute both and get the result of at least one of them if the other raises an exception.
Let's say I have:
def foo():
raise TypeError
def bar():
return 'bar'
If I do (adapted from here):
def multiple_exceptions(flist):
for f in flist:
try:
return f()
except:
continue
def main():
multiple_exceptions([foo, bar])
main()
main()
would return 'bar'
, but I'd like to be able to still throw the exception from foo()
after all. This way, I would still have the result of one of my functions and the information on the error occurred in the other.