MCPcopy Index your code
hub / github.com/nodejs/node / ProcessedTraceback

Class ProcessedTraceback

tools/inspector_protocol/jinja2/debug.py:80–129  ·  view source on GitHub ↗

Holds a Jinja preprocessed traceback for printing or reraising.

Source from the content-addressed store, hash-verified

78
79
80class ProcessedTraceback(object):
81 """Holds a Jinja preprocessed traceback for printing or reraising."""
82
83 def __init__(self, exc_type, exc_value, frames):
84 assert frames, 'no frames for this traceback?'
85 self.exc_type = exc_type
86 self.exc_value = exc_value
87 self.frames = frames
88
89 # newly concatenate the frames (which are proxies)
90 prev_tb = None
91 for tb in self.frames:
92 if prev_tb is not None:
93 prev_tb.set_next(tb)
94 prev_tb = tb
95 prev_tb.set_next(None)
96
97 def render_as_text(self, limit=None):
98 """Return a string with the traceback."""
99 lines = traceback.format_exception(self.exc_type, self.exc_value,
100 self.frames[0], limit=limit)
101 return ''.join(lines).rstrip()
102
103 def render_as_html(self, full=False):
104 """Return a unicode string with the traceback as rendered HTML."""
105 from jinja2.debugrenderer import render_traceback
106 return u'%s\n\n<!--\n%s\n-->' % (
107 render_traceback(self, full=full),
108 self.render_as_text().decode('utf-8', 'replace')
109 )
110
111 @property
112 def is_template_syntax_error(self):
113 """`True` if this is a template syntax error."""
114 return isinstance(self.exc_value, TemplateSyntaxError)
115
116 @property
117 def exc_info(self):
118 """Exception info tuple with a proxy around the frame objects."""
119 return self.exc_type, self.exc_value, self.frames[0]
120
121 @property
122 def standard_exc_info(self):
123 """Standard python exc_info for re-raising"""
124 tb = self.frames[0]
125 # the frame will be an actual traceback (or transparent proxy) if
126 # we are on pypy or a python implementation with support for tproxy
127 if type(tb) is not TracebackType:
128 tb = tb.tb
129 return self.exc_type, self.exc_value, tb
130
131
132def make_traceback(exc_info, source_hint=None):

Callers 1

translate_exceptionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…