exceptions.py 469 B

123456789101112131415161718192021222324
  1. def str_exc(e):
  2. try:
  3. # python 2.5 does this right!
  4. s = unicode(e)
  5. except:
  6. try:
  7. s = unicode(e.args[0])
  8. except:
  9. s = str(e)
  10. if ' : ' not in s:
  11. try:
  12. s = '%s : %s' % (e.__class__, s)
  13. except Exception, f:
  14. s = repr(e)
  15. return s
  16. def str_fault(e):
  17. if hasattr(e, 'faultString'):
  18. msg = e.faultString
  19. else:
  20. msg = str_exc(e)
  21. return msg