Fonction copie des librairies de cherrypy pour formatter le traceback
darcs-hash:20061205230757-f46e9-bd5ba336dd0b230ace414d61f1791d02c284b787.gz
This commit is contained in:
parent
baf4b7bd90
commit
7343af83bd
1 changed files with 50 additions and 0 deletions
50
lib/utils/exceptions.py
Executable file
50
lib/utils/exceptions.py
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
# #############################################################
|
||||
# ..
|
||||
# .... ............ ........
|
||||
# . ....... . .... ..
|
||||
# . ... .. .. .. .. ..... . ..
|
||||
# .. .. ....@@@. .. . ........ .
|
||||
# .. . .. ..@.@@..@@. .@@@@@@@ @@@@@@. ....
|
||||
# .@@@@. .@@@@. .@@@@..@@.@@..@@@..@@@..@@@@.... ....
|
||||
# @@@@... .@@@.. @@ @@ .@..@@..@@...@@@. .@@@@@. ..
|
||||
# .@@@.. . @@@. @@.@@..@@.@@..@@@ @@ .@@@@@@.. .....
|
||||
# ...@@@.... @@@ .@@.......... ........ ..... ..
|
||||
# . ..@@@@.. . .@@@@. .. ....... . .............
|
||||
# . .. .... .. .. . ... ....
|
||||
# . . .... ............. .. ...
|
||||
# .. .. ... ........ ... ...
|
||||
# ................................
|
||||
#
|
||||
# #############################################################
|
||||
"""
|
||||
exceptions.py
|
||||
|
||||
Fonctions pour gérer les exceptions
|
||||
|
||||
Copyright (c) 2006 by www.crans.org
|
||||
Some code, from cherrypy lib
|
||||
"""
|
||||
|
||||
import sys, traceback
|
||||
|
||||
|
||||
def formatExc(exc=None):
|
||||
"""formatExc(exc=None) -> exc (or sys.exc_info if None), formatted."""
|
||||
if exc is None:
|
||||
exc = sys.exc_info()
|
||||
|
||||
if exc == (None, None, None):
|
||||
return ""
|
||||
|
||||
page_handler_str = ""
|
||||
args = list(getattr(exc[1], "args", []))
|
||||
if args:
|
||||
if len(args) > 1:
|
||||
page_handler = args.pop()
|
||||
page_handler_str = 'Page handler: %s\n' % repr(page_handler)
|
||||
exc[1].args = tuple(args)
|
||||
return page_handler_str + "".join(traceback.format_exception(*exc))
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue