scripts/lib/utils/exceptions.py
Antoine Durand-Gasselin 4a68475e34 [wiki-lenny] suppression de static/
darcs-hash:20090314092631-bd074-b01256aeaf71e935851b3ecdbd623eaae8c9e8a1.gz
2009-03-14 10:26:31 +01:00

50 lines
1.7 KiB
Python

#!/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))