Does python have a "catch all" solution where if an error/exception is triggered anywhere in the script the error is passed to a custom function similar to how PHP's set_error_handler() function works?
I'm familiar with the try/catch method, but it's kind of a nuissance since the try/catch only works on the immediate code within in it.
def sample_function():
# some code that causes error, breaks script, does not pass error back to try/catch
try:
sample_function()
except Exception, e:
print str(e)
I'm looking for a simple try/except everything even if error is triggered within a function called from within a function without having to wrap every block of code with a try/except.
Does anyone know if this is possible?