From 5b1cd3bd3cb1b18172946276ae3dea03ec0531ea Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 26 Oct 2018 08:36:50 +0900 Subject: [PATCH] Fix bug --- src/server/api/call.ts | 2 +- src/server/api/endpoints/charts/drive.ts | 2 +- src/server/api/endpoints/charts/federation.ts | 2 +- src/server/api/endpoints/charts/hashtag.ts | 2 +- src/server/api/endpoints/charts/network.ts | 2 +- src/server/api/endpoints/charts/notes.ts | 2 +- src/server/api/endpoints/charts/user/drive.ts | 2 +- src/server/api/endpoints/charts/user/following.ts | 2 +- src/server/api/endpoints/charts/user/notes.ts | 2 +- src/server/api/endpoints/charts/user/reactions.ts | 2 +- src/server/api/endpoints/charts/users.ts | 2 +- src/server/api/endpoints/hashtags/search.ts | 2 +- src/server/api/endpoints/messaging/messages/read.ts | 2 +- src/server/api/endpoints/notes.ts | 2 +- src/server/api/endpoints/notes/mentions.ts | 2 +- src/server/api/endpoints/notes/search_by_tag.ts | 2 +- src/server/api/endpoints/users/lists/update.ts | 2 +- src/server/api/endpoints/users/notes.ts | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/server/api/call.ts b/src/server/api/call.ts index 7419bdc95d..20cb1ab7d5 100644 --- a/src/server/api/call.ts +++ b/src/server/api/call.ts @@ -62,7 +62,7 @@ export default (endpoint: string, user: IUser, app: IApp, data: any, file?: any) console.warn(`SLOW API CALL DETECTED: ${ep.name} (${time}ms)`); } } catch (e) { - rej(e); + rej(e.message); return; } diff --git a/src/server/api/endpoints/charts/drive.ts b/src/server/api/endpoints/charts/drive.ts index 79a2d59998..dc18331847 100644 --- a/src/server/api/endpoints/charts/drive.ts +++ b/src/server/api/endpoints/charts/drive.ts @@ -25,7 +25,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await driveChart.getChart(ps.span as any, ps.limit); diff --git a/src/server/api/endpoints/charts/federation.ts b/src/server/api/endpoints/charts/federation.ts index 2292c2e6a8..5b24783c69 100644 --- a/src/server/api/endpoints/charts/federation.ts +++ b/src/server/api/endpoints/charts/federation.ts @@ -25,7 +25,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await federationChart.getChart(ps.span as any, ps.limit); diff --git a/src/server/api/endpoints/charts/hashtag.ts b/src/server/api/endpoints/charts/hashtag.ts index c97a8c11dc..bcd48dc485 100644 --- a/src/server/api/endpoints/charts/hashtag.ts +++ b/src/server/api/endpoints/charts/hashtag.ts @@ -31,7 +31,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await hashtagChart.getChart(ps.span as any, ps.limit, ps.tag); diff --git a/src/server/api/endpoints/charts/network.ts b/src/server/api/endpoints/charts/network.ts index ed3a9c232e..d5b0791994 100644 --- a/src/server/api/endpoints/charts/network.ts +++ b/src/server/api/endpoints/charts/network.ts @@ -25,7 +25,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await networkChart.getChart(ps.span as any, ps.limit); diff --git a/src/server/api/endpoints/charts/notes.ts b/src/server/api/endpoints/charts/notes.ts index b24bfc638d..573b012469 100644 --- a/src/server/api/endpoints/charts/notes.ts +++ b/src/server/api/endpoints/charts/notes.ts @@ -25,7 +25,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await notesChart.getChart(ps.span as any, ps.limit); diff --git a/src/server/api/endpoints/charts/user/drive.ts b/src/server/api/endpoints/charts/user/drive.ts index 092f697f5d..2626c36c9d 100644 --- a/src/server/api/endpoints/charts/user/drive.ts +++ b/src/server/api/endpoints/charts/user/drive.ts @@ -33,7 +33,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await perUserDriveChart.getChart(ps.span as any, ps.limit, ps.userId); diff --git a/src/server/api/endpoints/charts/user/following.ts b/src/server/api/endpoints/charts/user/following.ts index 7918b9a9d5..57c15cdcfe 100644 --- a/src/server/api/endpoints/charts/user/following.ts +++ b/src/server/api/endpoints/charts/user/following.ts @@ -33,7 +33,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await perUserFollowingChart.getChart(ps.span as any, ps.limit, ps.userId); diff --git a/src/server/api/endpoints/charts/user/notes.ts b/src/server/api/endpoints/charts/user/notes.ts index cd028d88a2..66051fa7c6 100644 --- a/src/server/api/endpoints/charts/user/notes.ts +++ b/src/server/api/endpoints/charts/user/notes.ts @@ -33,7 +33,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await perUserNotesChart.getChart(ps.span as any, ps.limit, ps.userId); diff --git a/src/server/api/endpoints/charts/user/reactions.ts b/src/server/api/endpoints/charts/user/reactions.ts index 8632044ffa..60cdaa70bb 100644 --- a/src/server/api/endpoints/charts/user/reactions.ts +++ b/src/server/api/endpoints/charts/user/reactions.ts @@ -33,7 +33,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await perUserReactionsChart.getChart(ps.span as any, ps.limit, ps.userId); diff --git a/src/server/api/endpoints/charts/users.ts b/src/server/api/endpoints/charts/users.ts index 48dc31c882..595bb63f0b 100644 --- a/src/server/api/endpoints/charts/users.ts +++ b/src/server/api/endpoints/charts/users.ts @@ -25,7 +25,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const stats = await usersChart.getChart(ps.span as any, ps.limit); diff --git a/src/server/api/endpoints/hashtags/search.ts b/src/server/api/endpoints/hashtags/search.ts index f6fb35b2ff..69cdc62ab8 100644 --- a/src/server/api/endpoints/hashtags/search.ts +++ b/src/server/api/endpoints/hashtags/search.ts @@ -35,7 +35,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const hashtags = await Hashtag .find({ diff --git a/src/server/api/endpoints/messaging/messages/read.ts b/src/server/api/endpoints/messaging/messages/read.ts index 581b57579b..1c0bdf5230 100644 --- a/src/server/api/endpoints/messaging/messages/read.ts +++ b/src/server/api/endpoints/messaging/messages/read.ts @@ -26,7 +26,7 @@ export const meta = { export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); const message = await Message.findOne({ _id: ps.messageId, diff --git a/src/server/api/endpoints/notes.ts b/src/server/api/endpoints/notes.ts index d65710d33f..4f5a211240 100644 --- a/src/server/api/endpoints/notes.ts +++ b/src/server/api/endpoints/notes.ts @@ -56,7 +56,7 @@ export const meta = { export default (params: any) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); // Check if both of sinceId and untilId is specified if (ps.sinceId && ps.untilId) { diff --git a/src/server/api/endpoints/notes/mentions.ts b/src/server/api/endpoints/notes/mentions.ts index 27b6245eb6..7de0102c6d 100644 --- a/src/server/api/endpoints/notes/mentions.ts +++ b/src/server/api/endpoints/notes/mentions.ts @@ -36,7 +36,7 @@ export const meta = { export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); // Check if both of sinceId and untilId is specified if (ps.sinceId && ps.untilId) { diff --git a/src/server/api/endpoints/notes/search_by_tag.ts b/src/server/api/endpoints/notes/search_by_tag.ts index d380f27f9c..e7fa15f768 100644 --- a/src/server/api/endpoints/notes/search_by_tag.ts +++ b/src/server/api/endpoints/notes/search_by_tag.ts @@ -111,7 +111,7 @@ export const meta = { export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); if (ps.includeUserUsernames != null) { const ids = erase(null, await Promise.all(ps.includeUserUsernames.map(async (username) => { diff --git a/src/server/api/endpoints/users/lists/update.ts b/src/server/api/endpoints/users/lists/update.ts index e6577eca4f..e39f66fb5b 100644 --- a/src/server/api/endpoints/users/lists/update.ts +++ b/src/server/api/endpoints/users/lists/update.ts @@ -32,7 +32,7 @@ export const meta = { export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); // Fetch the list const userList = await UserList.findOne({ diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index 0b2fc06b04..8605a32dee 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -110,7 +110,7 @@ export const meta = { export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); - if (psErr) throw psErr; + if (psErr) return rej(psErr); if (ps.userId === undefined && ps.username === undefined) { return rej('userId or username is required');