Skip to content

Commit

Permalink
fix(core): double namespace if the error is thrown from parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL committed Dec 5, 2023
1 parent 7dee6a8 commit ad2e967
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/middleware/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ module.exports = async (ctx, next) => {
});
}
} catch (err) {
// Append v2 route path
ctx.request.path = (ctx.mountPath ?? '') + ctx.request.path;
ctx._matchedRoute = ctx._matchedRoute ? (ctx.mountPath ?? '') + ctx._matchedRoute : ctx.request.path;
if (err instanceof Error && !err.stack.split('\n')[0].includes('lib/middleware/parameter.js')) {
// Append v2 route path if a route throws an error
ctx.request.path = (ctx.mountPath ?? '') + ctx.request.path;
ctx._matchedRoute = ctx._matchedRoute ? (ctx.mountPath ?? '') + ctx._matchedRoute : ctx.request.path;
}

let message = err;
if (err.name && (err.name === 'HTTPError' || err.name === 'RequestError')) {
Expand Down

0 comments on commit ad2e967

Please sign in to comment.