Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/graphql/error/located_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def located_error(
return original_error
try:
# noinspection PyUnresolvedReferences
message = original_error.message # type: ignore
message = str(original_error.message) # type: ignore
except AttributeError:
message = str(original_error)
try:
Expand Down
23 changes: 23 additions & 0 deletions tests/error/test_located_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from graphql.error import GraphQLError, located_error

from ..utils import dedent


def describe_located_error():
def throws_without_an_original_error():
Expand All @@ -23,3 +25,24 @@ def does_not_pass_through_elasticsearch_like_errors():
e = Exception("I am from elasticsearch")
cast(Any, e).path = "/something/feed/_search"
assert located_error(e, [], []) is not e

def handles_proxy_error_messages():
class ProxyString:
def __init__(self, value):
self.value = value

def __str__(self):
return self.value

class MyError(Exception):
def __init__(self):
self.message = ProxyString("Example error")
super().__init__()

error = located_error(MyError(), [], [])

assert str(error) == dedent(
"""
Example error
"""
)