Es para ponerla en un except, para mostrar un mensaje, y luego el texto de la excepcion:
- Código: Seleccionar todo
def formatExceptionInfo():
""" formatExceptionInfo extracts and returns() the name and value of an exception """
cla, exc, trbk = sys.exc_info()
excName = cla.__name__
try:
excArgs = exc.__dict__["args"]
except KeyError:
excArgs = "<no args>"
return (excName, excArgs)
def msgerror(msg):
unused,e = formatExceptionInfo()
print msg
print "Error Details: " + e[0]
Pretty sencilla