In a language that uses exceptions for signal errors, I want to call some third-party code, and if it doesn't work, run the backup code instead. For example:
try: result = third_party.fast_calculation() catch: result = slower_calculation()
In my experience, it is very rare to find out all the exceptions that may be caused by third-party code. Therefore, I cannot list these exceptions in the catch clause. On the other hand, I am often not encouraged to catch all possible exceptions.
How do I write a catch clause in this situation?
language-agnostic exception exception-handling robustness
user200783
source share