node-mysql Rethrow non-MySQL errors

Jeremy picture Jeremy · May 2, 2016 · Viewed 10.2k times · Source

I just switched my node api over to use node-mysql. It keeps suppressing my errors/stack traces making development and debugging a nightmare. For example, I am writing a new feature and I get this error:

/opt/figo/banking/node_modules/mysql/lib/protocol/Parser.js:78
    throw err; // Rethrow non-MySQL errors
          ^
TypeError: string is not a function

The mysql module is essential re-wording my original error messages. How can I get it to stop doing this? I want to just see exactly where it failed, not where node-mysql decided to rethrow my error.

Answer

Arun Killu picture Arun Killu · Aug 11, 2017

If you are throwing error it should a valid error object.I think you are throwing string.Try this

throw new Error("oops something happened");