mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
feat(pkg): error handling
This commit is contained in:
@@ -26,13 +26,24 @@ module.exports = async (ctx, next) => {
|
||||
message = err.stack;
|
||||
}
|
||||
logger.error(`Error in ${ctx.request.path}: ${message}`);
|
||||
ctx.set({
|
||||
'Content-Type': 'text/html; charset=UTF-8',
|
||||
});
|
||||
ctx.body = art(path.resolve(__dirname, '../views/error.art'), {
|
||||
message,
|
||||
});
|
||||
ctx.status = 404;
|
||||
|
||||
if (config.isPackage) {
|
||||
ctx.body = {
|
||||
error: {
|
||||
message: err.message,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
ctx.set({
|
||||
'Content-Type': 'text/html; charset=UTF-8',
|
||||
});
|
||||
ctx.body = art(path.resolve(__dirname, '../views/error.art'), {
|
||||
message,
|
||||
});
|
||||
if (ctx.status !== 403) {
|
||||
ctx.status = 404;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx.debug.errorPaths[ctx.request.path]) {
|
||||
ctx.debug.errorPaths[ctx.request.path] = 0;
|
||||
|
||||
Reference in New Issue
Block a user