我刚刚切换节点api以使用node-mysql。它不断抑制我的错误/堆栈跟踪,使开发和调试成为一场噩梦。例如,我正在编写一个新功能,我收到此错误:
/opt/figo/banking/node_modules/mysql/lib/protocol/Parser.js:78
throw err; // Rethrow non-MySQL errors
^
TypeError: string is not a function
mysql
模块是重写我原始错误消息的必要条件。我怎么能让它停止这样做?我想知道它失败的确切位置,而不是node-mysql
决定重新抛出我的错误。
如果你抛出错误它应该是一个有效的错误对象。我认为你正在抛出字符串。试试这个
throw new Error("oops something happened");
你正在通过string
而不是int
或int
而不是string
我的意思是,你使用错误的value
传递data type
。不是为了mysql而是为了其他功能,请逐步检查。
检查你正在使用的data type
的var
console.log(typeof(yourVar));