In Python, what's the best way to catch "all" exceptions?
except: # do stuff with sys.exc_info()[1]
except BaseException as exc:
except Exception as exc:
The catch may be executing in a thread.
My aim is to log any exception that might be thrown by normal code without masking any special Python exceptions, such as those that indicate process termination etc.
Getting a handle to the exception (such as by the clauses above that contain exc
) is also desirable.