Ejemplo n.º 1
0
def _serializable_error_info_from_tb(
        tb: traceback.TracebackException) -> SerializableErrorInfo:
    return SerializableErrorInfo(
        # usually one entry, multiple lines for SyntaxError
        "".join(list(tb.format_exception_only())),
        tb.stack.format(),
        tb.exc_type.__name__ if tb.exc_type is not None else None,
        _serializable_error_info_from_tb(tb.__cause__)
        if tb.__cause__ else None,
    )
Ejemplo n.º 2
0
 def from_exc_info(cls, artifact_name, exc_info):
     te = TracebackException(*exc_info)
     # NB: we have dropped werkzeug's support for Paste's __traceback_hide__
     # frame local.
     return cls(
         {
             "artifact": artifact_name,
             "exception": "".join(te.format_exception_only()).strip(),
             "traceback": "".join(te.format()).strip(),
         }
     )