mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
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:
parent
6e96f44f39
commit
d2bb50a436
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user