Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix stacktrace mangling in patch_inline_callbacks (#7554)
Browse files Browse the repository at this point in the history
`Failure()` is more cunning than `Failure(e)`.
  • Loading branch information
richvdh authored May 22, 2020
1 parent d84bdfe commit a0f99f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/7554.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix some test code to not mangle stacktraces, to make it easier to debug errors.
9 changes: 7 additions & 2 deletions synapse/util/patch_inline_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,15 @@ def check_yield_points_inner(*args, **kwargs):
)
raise Exception(err)

# the wrapped function yielded a Deferred: yield it back up to the parent
# inlineCallbacks().
try:
result = yield d
except Exception as e:
result = Failure(e)
except Exception:
# this will fish an earlier Failure out of the stack where possible, and
# thus is preferable to passing in an exeception to the Failure
# constructor, since it results in less stack-mangling.
result = Failure()

if current_context() != expected_context:

Expand Down

0 comments on commit a0f99f8

Please sign in to comment.