summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/auth/session/show.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2019-02-22 11:46:58 +0900
committerGitHub <noreply@github.com>2019-02-22 11:46:58 +0900
commit2756f553c68082342a784ef716c62da6cea6f3ca (patch)
tree1e0364ca9ddc1fd88e311f0687746f44e007effd /src/server/api/endpoints/auth/session/show.ts
parentUpdate CHANGELOG.md (diff)
downloadmisskey-2756f553c68082342a784ef716c62da6cea6f3ca.tar.gz
misskey-2756f553c68082342a784ef716c62da6cea6f3ca.tar.bz2
misskey-2756f553c68082342a784ef716c62da6cea6f3ca.zip
Improve error handling of API (#4345)
* wip * wip * wip * Update attached_notes.ts * wip * Refactor * wip * wip * wip * wip * wip * wip * wip * wip * Update call.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * :v: * Fix
Diffstat (limited to 'src/server/api/endpoints/auth/session/show.ts')
-rw-r--r--src/server/api/endpoints/auth/session/show.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/server/api/endpoints/auth/session/show.ts b/src/server/api/endpoints/auth/session/show.ts
index cc63c43ad3..5e9e68c2c4 100644
--- a/src/server/api/endpoints/auth/session/show.ts
+++ b/src/server/api/endpoints/auth/session/show.ts
@@ -1,6 +1,7 @@
import $ from 'cafy';
import AuthSess, { pack } from '../../../../../models/auth-session';
import define from '../../../define';
+import { ApiError } from '../../../error';
export const meta = {
requireCredential: false,
@@ -9,19 +10,26 @@ export const meta = {
token: {
validator: $.str
}
+ },
+
+ errors: {
+ noSuchSession: {
+ message: 'No such session.',
+ code: 'NO_SUCH_SESSION',
+ id: 'bd72c97d-eba7-4adb-a467-f171b8847250'
+ }
}
};
-export default define(meta, (ps, user) => new Promise(async (res, rej) => {
+export default define(meta, async (ps, user) => {
// Lookup session
const session = await AuthSess.findOne({
token: ps.token
});
if (session == null) {
- return rej('session not found');
+ throw new ApiError(meta.errors.noSuchSession);
}
- // Response
- res(await pack(session, user));
-}));
+ return await pack(session, user);
+});