From 1de69e5d2b95f17487b839bb97cac5d3e5465c06 Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Thu, 19 May 2016 18:14:49 +0100 Subject: [PATCH 1/3] Add right stack trace to exception --- graphql/execution/executor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphql/execution/executor.py b/graphql/execution/executor.py index 313a3e10..08ffa818 100644 --- a/graphql/execution/executor.py +++ b/graphql/execution/executor.py @@ -1,6 +1,7 @@ import collections import functools import logging +import sys from promise import Promise, is_thenable, promise_for_dict, promisify @@ -170,6 +171,7 @@ def resolve_or_error(resolve_fn, source, args, context, info, executor): logger.exception("An error occurred while resolving field {}.{}".format( info.parent_type.name, info.field_name )) + e.stack = sys.exc_info()[2] return e From 7ad0795867efa6409c7e10c767dff9d68a973f29 Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Thu, 19 May 2016 18:15:56 +0100 Subject: [PATCH 2/3] Always take the original stack --- graphql/error/located_error.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/graphql/error/located_error.py b/graphql/error/located_error.py index c095ea17..43c2517c 100644 --- a/graphql/error/located_error.py +++ b/graphql/error/located_error.py @@ -13,10 +13,7 @@ def __init__(self, nodes, original_error=None): else: message = 'An unknown error occurred.' - if isinstance(original_error, GraphQLError): - stack = original_error.stack - else: - stack = sys.exc_info()[2] + stack = original_error.stack super(GraphQLLocatedError, self).__init__( message=message, From e398c5329790431266e6400f80c82d07e3310f43 Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Thu, 19 May 2016 23:39:27 +0100 Subject: [PATCH 3/3] Only use existing stack if the error has one. --- graphql/error/located_error.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/graphql/error/located_error.py b/graphql/error/located_error.py index 43c2517c..87ded24e 100644 --- a/graphql/error/located_error.py +++ b/graphql/error/located_error.py @@ -13,7 +13,10 @@ def __init__(self, nodes, original_error=None): else: message = 'An unknown error occurred.' - stack = original_error.stack + if hasattr(original_error, 'stack'): + stack = original_error.stack + else: + stack = sys.exc_info()[2] super(GraphQLLocatedError, self).__init__( message=message,