Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/graphql/error/graphql_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def __init__(
self.__cause__ = original_error.__cause__
elif original_error.__context__:
self.__context__ = original_error.__context__
self.__suppress_context__ = original_error.__suppress_context__

if extensions is None and underlying_error is not None:
original_extensions = getattr(underlying_error, "extensions", None)
Expand Down
13 changes: 13 additions & 0 deletions tests/error/test_graphql_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ def passes_the_context_of_an_original_error():
e = GraphQLError("msg", original_error=original)
assert e.__context__ is context

def passes_the_suppressed_context_of_an_original_error():
context = ValueError("hidden")
try:
raise context
except ValueError:
try:
raise RuntimeError("effect") from None
except RuntimeError as runtime_error:
original = runtime_error
e = GraphQLError("msg", original_error=original)
assert e.__context__ is context
assert e.__suppress_context__ is True

def passes_the_cause_of_an_original_error():
cause = ValueError("cause")
try:
Expand Down