Skip to content

Commit

Permalink
Add requested path to router error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kuuttia committed Apr 13, 2017
1 parent 4eeb805 commit bf95608
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions route/router/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Route.prototype.public = function () {

/**
* This handler sends response by itself and we shouldn't apply default response sending actions for this one.
*
*
* Handler must return promise, which doesn't resolve until res.send is called.
*
* @returns {Route}
Expand Down Expand Up @@ -148,7 +148,8 @@ Route.prototype.handlerMiddleware_ = function (req, res, next) {
return promise.then(function (result) {
if (result === NO_RESULT) {
if (!res.headersSent) {
throw new Error("Handler function did not return promise which won't resolve until response has been sent.");
throw new Error("Handler function did not return promise which won't resolve until response has been sent. " +
"Requested path: " + req.path);
}
return;
}
Expand All @@ -158,7 +159,8 @@ Route.prototype.handlerMiddleware_ = function (req, res, next) {
sendResult(result, req, res);
}
if (!res.headersSent) {
throw new Error("Unexpected error, response was not sent by any handler for some reason. This should not be possible.");
throw new Error("Unexpected error, response was not sent by any handler for some reason. " +
"Requested path: " + req.path);
}
}).catch(next);
};
Expand All @@ -182,7 +184,7 @@ Route.prototype.handle_ = function (req, res, next) {
if (this.defaultAuthHandler) {
authHandlers.unshift(this.defaultAuthHandler);
} else {
throw new Error("No defaultAuthHandler set for non-public route.");
throw new Error("No defaultAuthHandler set for non-public route. Requested path: " + req.path);
}
}

Expand All @@ -197,7 +199,7 @@ Route.prototype.handle_ = function (req, res, next) {
} else if (ret instanceof Error) {
throw ret;
} else {
throw new Error("Invalid return value from auth handler.");
throw new Error("Invalid return value from auth handler. Requested path: " + req.path);
}
});
});
Expand Down

0 comments on commit bf95608

Please sign in to comment.