如果在处理来自RabbitMQ的传入消息的node.js函数中抛出错误,则堆栈跟踪来自node-amqp代码而不是我的处理程序中的错误(并且错误通常是“无法调用未定义的方法indexOf”,不管实际的错误是什么) .
有没有办法让我的代码执行堆栈跟踪而不是在node-amqp模块的“边缘”停止的代码?
堆栈跟踪示例:
stackTrace=TypeError: Cannot call method 'indexOf' of undefined
at Queue._onMethod (/myproject/node_modules/besedoq/node_modules/amqp/lib/queue.js:398:23)
at Queue.Channel._onChannelMethod (/myproject/node_modules/besedoq/node_modules/amqp/lib/channel.js:85:12)
at Connection._onMethod (/myproject/node_modules/besedoq/node_modules/amqp/lib/connection.js:443:28)
at AMQPParser.self.parser.onMethod (/myproject/node_modules/besedoq/node_modules/amqp/lib/connection.js:136:12)
1 回答
在你的堆栈跟踪引用的行中的lib似乎缺少队列的名称,如果你给你的队列命名 - 也许你会得到更好的堆栈跟踪?
https://github.com/postwait/node-amqp/blob/master/lib/queue.js#L398