AriaMinaei/pretty-error

Error message is stripped if stack exists

Opened this issue · 6 comments

It seems as though the error's message is stripped if a stack trace is present (ParsedError.coffee:25):

      if typeof @_stack is 'string'
        @_parseStack()
      else
        @_message = @error.message? and String(@error.message) or ''

Resulting in something like:
screen shot 2016-04-29 at 8 50 01 pm
(when no stack is present)

And this when there is a stack:
screen shot 2016-04-29 at 8 49 46 pm

Currently when parsing the Error, we expect the .stack to actually start with a copy of the .message and then continue with the trace lines. That's how most stacks are composed. But I'm sure situations like the one you encountered do occur where the message is not embedded in the stack.

The fix is probably trivial. When parsing the stack and extracting the message, we can compare our extracted message with the string inside .message, and if they don't match, we'd prepend .message to the extracted one.

I can do that, but first, I need a minimal reproduction of the situation, if you can provide that please.

I have the same issue in Node.js API Starter Kit (see src/app.js).

Same problem here

Guys, I need a minimal reproduction of this error to be able to fix it :) A minimal reproduction would be one package.json file, one index.js file, and running $ node index.js should reproduce the error.

I have this problem with GraphQLError instances. I will see if I can make some steps to reproduce.

Never mind, that situation seems to have been fixed very recently: graphql/graphql-js#718.