feat: add error routes and error paths info

This commit is contained in:
DIYgod
2019-08-23 00:15:13 +08:00
parent 6dc109b55c
commit f7e8682ba8
5 changed files with 50 additions and 4 deletions

View File

@@ -10,5 +10,15 @@ module.exports = async (ctx, next) => {
});
ctx.body = `RSSHub 发生了一些意外: <pre>${err instanceof Error ? err.stack : err}</pre>`;
ctx.status = 404;
if (!ctx.debug.errorPaths[ctx.request.path]) {
ctx.debug.errorPaths[ctx.request.path] = 0;
}
ctx.debug.errorPaths[ctx.request.path]++;
if (!ctx.debug.errorRoutes[ctx._matchedRoute]) {
ctx.debug.errorRoutes[ctx._matchedRoute] = 0;
}
ctx.debug.errorRoutes[ctx._matchedRoute]++;
}
};