Fixing throwing errors the standard way

pull/5501/head
Leo Giovanetti 2022-11-16 15:56:09 -03:00
parent a7bd83c4fb
commit bb1bb410fa
2 changed files with 3 additions and 3 deletions

View File

@ -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" }) };

View File

@ -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 });
}
}