+
+def format_exception(msg, limit=None, trace=None):
+ """
+ Format a stack trace and the exception information.
+ as traceback.format_exception(), without color
+ with traceback only if (_debug) or (DBG._user in DBG._developers)
+ """
+ etype, value, tb = sys.exc_info()
+ res = msg
+ if tb:
+ res += "\nTraceback (most recent call last):\n"
+ res += "".join(traceback.format_tb(tb, limit)) # [:-1])
+ res += "\n"
+ res += "\n".join(traceback.format_exception_only(etype, value))
+ return res
+
+def format_color_exception(msg, limit=None, trace=None):
+ """
+ Format a stack trace and the exception information.
+ as traceback.format_exception(), with color
+ with traceback only if _debug or isDeveloper())
+ """
+ etype, value, tb = sys.exc_info()
+ if _debug[-1] or isDeveloper():
+ res = "<red>" + msg
+ if tb:
+ res += "<yellow>\nTraceback (most recent call last):\n"
+ res += "".join(traceback.format_tb(tb, limit)) # [:-1])
+ res += "\n<red>"
+ res += "\n".join(traceback.format_exception_only(etype, value))
+ return res + "<reset>"
+ else:
+ res = "<red>" + msg # + "<bright>"
+ res += "".join(traceback.format_exception_only(etype, value))
+ return res + "<reset>"
+
+