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

Function translate_exception

tools/inspector_protocol/jinja2/debug.py:154–195  ·  view source on GitHub ↗

If passed an exc_info it will automatically rewrite the exceptions all the way down to the correct line numbers and frames.

(exc_info, initial_skip=0)

Source from the content-addressed store, hash-verified

152
153
154def translate_exception(exc_info, initial_skip=0):
155 """If passed an exc_info it will automatically rewrite the exceptions
156 all the way down to the correct line numbers and frames.
157 """
158 tb = exc_info[2]
159 frames = []
160
161 # skip some internal frames if wanted
162 for x in range(initial_skip):
163 if tb is not None:
164 tb = tb.tb_next
165 initial_tb = tb
166
167 while tb is not None:
168 # skip frames decorated with @internalcode. These are internal
169 # calls we can't avoid and that are useless in template debugging
170 # output.
171 if tb.tb_frame.f_code in internal_code:
172 tb = tb.tb_next
173 continue
174
175 # save a reference to the next frame if we override the current
176 # one with a faked one.
177 next = tb.tb_next
178
179 # fake template exceptions
180 template = tb.tb_frame.f_globals.get('__jinja_template__')
181 if template is not None:
182 lineno = template.get_corresponding_lineno(tb.tb_lineno)
183 tb = fake_exc_info(exc_info[:2] + (tb,), template.filename,
184 lineno)[2]
185
186 frames.append(make_frame_proxy(tb))
187 tb = next
188
189 # if we don't have any exceptions in the frames left, we have to
190 # reraise it unchanged.
191 # XXX: can we backup here? when could this happen?
192 if not frames:
193 reraise(exc_info[0], exc_info[1], exc_info[2])
194
195 return ProcessedTraceback(exc_info[0], exc_info[1], frames)
196
197
198def get_jinja_locals(real_locals):

Callers 1

make_tracebackFunction · 0.85

Calls 8

reraiseFunction · 0.90
fake_exc_infoFunction · 0.85
make_frame_proxyFunction · 0.85
ProcessedTracebackClass · 0.85
getMethod · 0.65
rangeFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…