scripts/cranslib/utils/exceptions.py
Vincent Le Gallic 10275229a1 Dans la série suppression des liens symboliques : /usr/scripts/lib devient /usr/scripts/cranslib
* Comme ça c'est plus clair que c'est un truc custom crans
 * Le lien symbolique /usr/scripts/gestion/crans/ est retiré. D'autres suivront.
2013-05-08 04:04:30 +02: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))