File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 6
6
from typing import TYPE_CHECKING , Collection
7
7
8
8
from ..pyutils import inspect
9
+ from ..language .source import is_source , Source
9
10
from .graphql_error import GraphQLError
10
11
11
12
if TYPE_CHECKING :
@@ -39,7 +40,9 @@ def located_error(
39
40
except AttributeError :
40
41
message = str (original_error )
41
42
try :
42
- source = original_error .source # type: ignore
43
+ source = original_error .source
44
+ if not is_source (source ):
45
+ source = Source (source ) if isinstance (source , str ) else None
43
46
except AttributeError :
44
47
source = None
45
48
try :
Original file line number Diff line number Diff line change @@ -35,3 +35,11 @@ def __init__(self):
35
35
super ().__init__ ()
36
36
37
37
assert str (located_error (LazyError ())) == "lazy"
38
+
39
+ def handles_error_with_str_source ():
40
+ class CustomException (Exception ):
41
+ def __init__ (self , message , source ):
42
+ super ().__init__ (message )
43
+ self .source = source
44
+ e = located_error (CustomException ("msg" , "source" ))
45
+ assert e .source and e .source .get_location (0 )
You can’t perform that action at this time.
0 commit comments