Refactored async function to throw errors

no-issue

There's no need to return rejected promises in an async function as
thrown errors will behave the same, this just makes it a little cleaner.
This commit is contained in:
Fabien O'Carroll 2020-09-28 13:06:58 +01:00
parent 6e96f44f39
commit d2bb50a436

View File

@ -164,9 +164,9 @@ module.exports = function MembersApi({
async function setMemberGeolocationFromIp(email, ip) {
if (!email || !ip) {
return Promise.reject(new common.errors.IncorrectUsageError({
throw new common.errors.IncorrectUsageError({
message: 'setMemberGeolocationFromIp() expects email and ip arguments to be present'
}));
});
}
const member = await users.get(email, {
@ -174,9 +174,9 @@ module.exports = function MembersApi({
});
if (!member) {
return Promise.reject(new common.errors.NotFoundError({
throw new common.errors.NotFoundError({
message: `Member with email address ${email} does not exist`
}));
});
}
// max request time is 500ms so shouldn't slow requests down too much