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 66from typing import TYPE_CHECKING , Collection
77
88from ..pyutils import inspect
9+ from ..language .source import is_source , Source
910from .graphql_error import GraphQLError
1011
1112if TYPE_CHECKING :
@@ -39,7 +40,9 @@ def located_error(
3940 except AttributeError :
4041 message = str (original_error )
4142 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
4346 except AttributeError :
4447 source = None
4548 try :
Original file line number Diff line number Diff line change @@ -35,3 +35,11 @@ def __init__(self):
3535 super ().__init__ ()
3636
3737 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