Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HandledGraphQLError that does not log an exception #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions graphql/error/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from .base import GraphQLError
from .base import GraphQLError, HandledGraphQLError
from .located_error import GraphQLLocatedError
from .syntax_error import GraphQLSyntaxError
from .format_error import format_error

__all__ = ["GraphQLError", "GraphQLLocatedError", "GraphQLSyntaxError", "format_error"]

__all__ = [
"GraphQLError",
"GraphQLLocatedError",
"GraphQLSyntaxError",
"HandledGraphQLError",
"format_error",
]
3 changes: 3 additions & 0 deletions graphql/error/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ def locations(self):
if self.positions and source:
self._locations = [get_location(source, pos) for pos in self.positions]
return self._locations

class HandledGraphQLError(GraphQLError):
pass
4 changes: 3 additions & 1 deletion graphql/execution/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from six import string_types
from promise import Promise, promise_for_dict, is_thenable

from ..error import GraphQLError, GraphQLLocatedError
from ..error import GraphQLError, GraphQLLocatedError, HandledGraphQLError
from ..pyutils.default_ordered_dict import DefaultOrderedDict
from ..pyutils.ordereddict import OrderedDict
from ..utils.undefined import Undefined
Expand Down Expand Up @@ -445,6 +445,8 @@ def resolve_or_error(
# type: (...) -> Any
try:
return executor.execute(resolve_fn, source, info, **args)
except HandledGraphQLError:
raise
except Exception as e:
logger.exception(
"An error occurred while resolving field {}.{}".format(
Expand Down