app: return 500 -> 404 when error happens

This commit is contained in:
DIYgod 2018-06-03 00:18:36 +08:00
parent 719382d812
commit 09a616d2b8
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
4 changed files with 4 additions and 7 deletions

View File

@ -9,6 +9,6 @@ module.exports = async (ctx, next) => {
'Content-Type': 'text/html; charset=UTF-8',
});
ctx.body = `RSSHub 发生了一些意外: <pre>${err instanceof Error ? err.stack : err}</pre>`;
ctx.status = 500;
ctx.status = 404;
}
};

View File

@ -6,8 +6,7 @@ module.exports = async (ctx) => {
const id = ctx.params.id;
if (!getToken()) {
ctx.throw(500);
return;
throw 'pixiv not login';
}
const [bookmarksResponse, userDetailResponse] = await Promise.all([getBookmarks(id, getToken()), getUserDetail(id, getToken())]);

View File

@ -36,8 +36,7 @@ module.exports = async (ctx) => {
const date = ctx.params.date ? new Date(ctx.params.date) : new Date();
if (!getToken()) {
ctx.throw(500);
return;
throw 'pixiv not login';
}
const response = await getRanking(mode, ctx.params.date && date, getToken());

View File

@ -5,8 +5,7 @@ module.exports = async (ctx) => {
const id = ctx.params.id;
if (!getToken()) {
ctx.throw(500);
return;
throw 'pixiv not login';
}
const response = await getIllusts(id, getToken());