我有以下Restify定义的路由处理程序。确定异常被神秘抛出
MyModule.prototype.uploadDateChecker = function (req, res, next) {
req.locals = {};
var handlerConfig = req._self = this;
//Uncommenting this line does throw the exception with the message.
//next(new Error("Test Error"));
var continueProcessing = commonUtils.processInputs(req, res, next, handlerConfig, __function, __line);
...
//If I uncomment this one instead, some other exception is thrown first somewhere resulting in: {"code":"InternalError","message":""}
//next(new Error("Test Error: "+continueProcessing));
出于某种原因,经过commonUtils.processInputs函数返回时,客户机接收具有“”的消息的500错误。如果我在调用processInputs之前添加一个
next(new Error("Test Error"));
,那么500错误在主体中有一个“测试错误”。如果我将它移动到processInputs之后,那么500没有消息。显然,另一个异常是从processInputs中引发任何消息。但是,如果我进入该processInputs并在返回之前,我添加下一个(新的错误(“测试错误”))语句,然后客户端得到测试错误。所以我不知道当抛出线被注释掉时如何/为什么会抛出空白消息。
ProcessInputs结束:
...
commonUtils.processOutputs = function (req, res, next, handlerConfig, func, line) {
var resp = commonUtils.enterExit(req, res, next, handlerConfig, func, line, "START");
//Uncommenting this line results in: {"message":"Test Error: true"}
//next(new Error("Test Error: "+resp));
return resp;
}
HTTP响应身体没有消息:
{"code":"InternalError","message":""}
HTTP响应体与所述消息(内侧processInputs):
{"message":"Test Error: true"}
没有一个看起来很喜欢。你确定这是关于调整吗? – HeadCode
@Head Coder,都是我的Restify路由器处理程序使用的所有帮助程序函数,并且我通过了req,res和next。 – user994165