Skip to content

Commit

Permalink
Add HandledGraphQLError that does not log an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Siecje committed Jan 31, 2019
1 parent 9202021 commit a6580ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit a6580ba

Please sign in to comment.