AriaMinaei / pretty-error

See node.js errors with less clutter
MIT License
1.52k stars 48 forks source link

Error message is stripped if stack exists #32

Open perry-mitchell opened 8 years ago

perry-mitchell commented 8 years ago

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
AriaMinaei commented 8 years ago

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.

koistya commented 7 years ago

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

lopezjurip commented 7 years ago

Same problem here

AriaMinaei commented 7 years ago

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.

jorrit commented 7 years ago

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

jorrit commented 7 years ago

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