node-mysql Rethrow非MySQL错误

问题描述 投票:4回答:2

我刚刚切换节点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决定重新抛出我的错误。

node.js node-mysql
2个回答
0
投票

如果你抛出错误它应该是一个有效的错误对象。我认为你正在抛出字符串。试试这个

throw new Error("oops something happened");

0
投票

你正在通过string而不是intint而不是string

我的意思是,你使用错误的value传递data type。不是为了mysql而是为了其他功能,请逐步检查。

检查你正在使用的data typevar

console.log(typeof(yourVar));
© www.soinside.com 2019 - 2024. All rights reserved.