Skip to content

Commit

Permalink
app: return 500 -> 404 when error happens
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jun 2, 2018
1 parent 719382d commit 09a616d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion middleware/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
3 changes: 1 addition & 2 deletions routes/pixiv/bookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())]);
Expand Down
3 changes: 1 addition & 2 deletions routes/pixiv/ranking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 1 addition & 2 deletions routes/pixiv/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 09a616d

Please sign in to comment.