MCPcopy Create free account
hub / github.com/tox-dev/filelock / append_exception_context

Function append_exception_context

src/filelock/_core/_errors.py:187–200  ·  view source on GitHub ↗
(error: BaseException, context: BaseException)

Source from the content-addressed store, hash-verified

185
186
187def append_exception_context(error: BaseException, context: BaseException) -> None:
188 if _exception_graph_contains(error, context) or _exception_graph_contains(context, error):
189 return
190 if error.__context__ is None:
191 error.__context__ = context
192 return
193 tail = error
194 seen: set[int] = set()
195 while id(tail) not in seen:
196 seen.add(id(tail))
197 if (next_error := tail.__cause__ if tail.__cause__ is not None else tail.__context__) is None:
198 tail.__context__ = context
199 return
200 tail = next_error
201
202
203def _exception_graph_contains(error: BaseException, target: BaseException) -> bool:

Calls 2

addMethod · 0.80