Better error handling

This commit is contained in:
syuilo
2019-04-14 04:17:24 +09:00
parent b390363b25
commit e3b3f8fac1
25 changed files with 52 additions and 52 deletions

View File

@@ -17,7 +17,7 @@ export async function resolveUser(username: string, host: string | null, option?
logger.info(`return local user: ${usernameLower}`);
return await Users.findOne({ usernameLower, host: null }).then(u => {
if (u == null) {
throw 'user not found';
throw new Error('user not found');
} else {
return u;
}
@@ -30,7 +30,7 @@ export async function resolveUser(username: string, host: string | null, option?
logger.info(`return local user: ${usernameLower}`);
return await Users.findOne({ usernameLower, host: null }).then(u => {
if (u == null) {
throw 'user not found';
throw new Error('user not found');
} else {
return u;
}
@@ -78,7 +78,7 @@ export async function resolveUser(username: string, host: string | null, option?
logger.info(`return resynced remote user: ${acctLower}`);
return await Users.findOne({ uri: self.href }).then(u => {
if (u == null) {
throw 'user not found';
throw new Error('user not found');
} else {
return u;
}