Raise error from function : raise « Statement « Python Tutorial






import sys

def excFunc() :
    raise ValueError

try:
    excFunc()
except:
    print "Got an exception"
    print sys.exc_info()








3.15.raise
3.15.1.raise Statement: raise [SomeException [, args [, traceback]]]
3.15.2.Raise value error
3.15.3.Raise error from function
3.15.4.raise ZeroDivisionError
3.15.5.raise exception-type