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

Unable to locate original location of Exception #207

Open
Drarok opened this issue Sep 21, 2018 · 3 comments
Open

Unable to locate original location of Exception #207

Drarok opened this issue Sep 21, 2018 · 3 comments

Comments

@Drarok
Copy link

Drarok commented Sep 21, 2018

In executor.py, there is the following code:

if isinstance(result, Exception):
    raise GraphQLLocatedError(field_asts, original_error=result, path=path)

This appears to swallow the original error (result) as it doesn't appear in any tracebacks, leading me to lose my mind trying to work out where an error is actually being thrown. In my local install I have changed it to this in order to chain the exceptions:

if isinstance(result, Exception):
    raise GraphQLLocatedError(field_asts, original_error=result, path=path) from result

This gives me the full original exception's stack trace to look at when I'm debugging, and allows me to regain some sanity. I don't know if there any any knock-on effects though, which is why I didn't create this as a pull request. I'd love to hear your thoughts!

@wapiflapi
Copy link

wapiflapi commented Sep 22, 2018

Thanks for taking the time to post this and contribute a solution!

I don't have any insight on the problem at hand directly (your code looks good!) but one small problem you'll need to look into when doing a PR is compatibility with Python 2. You probably want to be using https://pythonhosted.org/six/#six.raise_from instead of raise X from Y. The project is already using six for compatibility.

If we fix compatibility I don't know of any bad side effects, so if it helps you its probably useful and deserves a PR!

@feus4177
Copy link

Unfortunately, @Drarok's solution didn't work for me. It is incredibly frustrating not having a stack trace in the logs.

@ykiu
Copy link

ykiu commented Mar 6, 2019

@feus4177
As a temporary workaround I changed this function at executor.py like

            def handle_error(error):
                import traceback; traceback.print_tb(error.original_error.__traceback__)  # this line has been inserted
                # type: (Union[GraphQLError, GraphQLLocatedError]) -> Optional[Any]
                traceback = completed._traceback  # type: ignore
                exe_context.report_error(error, traceback)
                return None

and it now prints stack traces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants