Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Aug 12, 2019
1 parent 6f8581a commit 89fd61b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions ariadne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions ariadne/format_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_error_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ariadne.format_error import (
format_error,
get_error_extension,
get_formatted_context,
get_formatted_error_context,
)


Expand Down Expand Up @@ -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

0 comments on commit 89fd61b

Please sign in to comment.