From bb1bb410fac6f8c6ad14c3163a8433d125f7a885 Mon Sep 17 00:00:00 2001 From: Leo Giovanetti Date: Wed, 16 Nov 2022 15:56:09 -0300 Subject: [PATCH] Fixing throwing errors the standard way --- packages/app-store/sendgrid/api/_postAdd.ts | 2 +- packages/app-store/sendgrid/api/_postCheck.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/app-store/sendgrid/api/_postAdd.ts b/packages/app-store/sendgrid/api/_postAdd.ts index 70e1397418..31f94eb883 100644 --- a/packages/app-store/sendgrid/api/_postAdd.ts +++ b/packages/app-store/sendgrid/api/_postAdd.ts @@ -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" }) }; diff --git a/packages/app-store/sendgrid/api/_postCheck.ts b/packages/app-store/sendgrid/api/_postCheck.ts index fd3b0f34ba..57c8f44247 100644 --- a/packages/app-store/sendgrid/api/_postCheck.ts +++ b/packages/app-store/sendgrid/api/_postCheck.ts @@ -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 }); } }