Fixing throwing errors the standard way
parent
a7bd83c4fb
commit
bb1bb410fa
|
@ -30,7 +30,7 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||
});
|
||||
} catch (reason) {
|
||||
logger.error("Could not add Sendgrid app", reason);
|
||||
return { message: "Could not add Sendgrid app", statusCode: 500 };
|
||||
throw new HttpError({ message: "Could not add Sendgrid app", statusCode: 500 });
|
||||
}
|
||||
|
||||
return { url: getInstalledAppPath({ variant: "other", slug: "sendgrid" }) };
|
||||
|
|
|
@ -19,10 +19,10 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||
if (usernameInfo.username) {
|
||||
return {};
|
||||
} else {
|
||||
return { statusCode: 404 };
|
||||
throw new HttpError({ statusCode: 404 });
|
||||
}
|
||||
} catch (e) {
|
||||
return { message: e, statusCode: 500 };
|
||||
throw new HttpError({ statusCode: 500, message: e as string });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue