Skip to content

Instantly share code, notes, and snippets.

@kjaquier
Last active January 1, 2016 13:19
Show Gist options
  • Save kjaquier/8150511 to your computer and use it in GitHub Desktop.
Save kjaquier/8150511 to your computer and use it in GitHub Desktop.
Informations d'exception
def current_exception_details():
"""Retourne un tuple contenant les les informations sur l'exception
en cours de traitement
Retour : (
Nom du fichier,
Ligne,
Nom de l'exception,
Type de l'exception,
Message de l'exception
)
"""
# http://docs.python.org/2/library/sys.html#sys.exc_info
return (
sys.exc_info()[2].tb_frame.f_code.co_filename,
sys.exc_info()[2].tb_lineno,
sys.exc_info()[2].tb_frame.f_code.co_name,
sys.exc_info()[0].__name__,
sys.exc_info()[1].message
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment