diff --git a/ariadne/__init__.py b/ariadne/__init__.py index 71a3188d9..7316fbb77 100644 --- a/ariadne/__init__.py +++ b/ariadne/__init__.py @@ -5,8 +5,8 @@ from .format_error import ( format_error, get_error_extension, - get_formatted_context, - get_formatted_traceback, + get_formatted_error_context, + get_formatted_error_traceback, ) from .graphql import graphql, graphql_sync, subscribe from .interfaces import InterfaceType @@ -50,8 +50,8 @@ "fallback_resolvers", "format_error", "get_error_extension", - "get_formatted_context", - "get_formatted_traceback", + "get_formatted_error_context", + "get_formatted_error_traceback", "gql", "graphql", "graphql_sync", diff --git a/ariadne/format_error.py b/ariadne/format_error.py index c28e5a8cf..15894cedd 100644 --- a/ariadne/format_error.py +++ b/ariadne/format_error.py @@ -24,19 +24,19 @@ def get_error_extension(error: GraphQLError) -> Optional[dict]: unwrapped_error = cast(Exception, unwrapped_error) return { - "stacktrace": get_formatted_traceback(unwrapped_error), - "context": get_formatted_context(unwrapped_error), + "stacktrace": get_formatted_error_traceback(unwrapped_error), + "context": get_formatted_error_context(unwrapped_error), } -def get_formatted_traceback(error: Exception) -> List[str]: +def get_formatted_error_traceback(error: Exception) -> List[str]: formatted = [] for line in format_exception(type(error), error, error.__traceback__): formatted.extend(line.rstrip().splitlines()) return formatted -def get_formatted_context(error: Exception) -> Optional[dict]: +def get_formatted_error_context(error: Exception) -> Optional[dict]: tb_last = error.__traceback__ while tb_last and tb_last.tb_next: tb_last = tb_last.tb_next diff --git a/tests/test_error_formatting.py b/tests/test_error_formatting.py index d34b5a362..5e893378b 100644 --- a/tests/test_error_formatting.py +++ b/tests/test_error_formatting.py @@ -8,7 +8,7 @@ from ariadne.format_error import ( format_error, get_error_extension, - get_formatted_context, + get_formatted_error_context, ) @@ -86,4 +86,4 @@ def test_error_extension_is_not_available_for_error_without_traceback(): def test_incomplete_traceback_is_handled_by_context_extractor(): error = Mock(__traceback__=None, spec=["__traceback__"]) - assert get_formatted_context(error) is None + assert get_formatted_error_context(error) is None