Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

don't throw error, return response instead

Steven Teyc3b05f8f306e
diff --git a/apps/web/app/api/auth/saml/callback/route.ts b/apps/web/app/api/auth/saml/callback/route.ts
index e8490b105a..055838d4d7 100644
--- a/apps/web/app/api/auth/saml/callback/route.ts
+++ b/apps/web/app/api/auth/saml/callback/route.ts
@@ -15,7 +15,9 @@ export async function POST(req: Request) {
});
if (!redirect_url) {
- throw new Error("No redirect URL found.");
+ return new Response("No redirect URL found.", {
+ status: 400,
+ });
}
return NextResponse.redirect(redirect_url, {
diff --git a/apps/web/app/api/auth/saml/userinfo/route.ts b/apps/web/app/api/auth/saml/userinfo/route.ts
index 28df3070f8..6c10125694 100644
--- a/apps/web/app/api/auth/saml/userinfo/route.ts
+++ b/apps/web/app/api/auth/saml/userinfo/route.ts
@@ -7,7 +7,9 @@ export async function GET(req: Request) {
const authHeader = req.headers.get("Authorization");
if (!authHeader) {
- throw new Error("Unauthorized");
+ return new Response("Unauthorized", {
+ status: 401,
+ });
}
const token = authHeader.split(" ")[1];
diff --git a/apps/web/app/api/callback/stripe/route.ts b/apps/web/app/api/callback/stripe/route.ts
index 9bf7a4c386..7d2e58aacf 100644
--- a/apps/web/app/api/callback/stripe/route.ts
+++ b/apps/web/app/api/callback/stripe/route.ts
@@ -178,7 +178,9 @@ export const POST = async (req: Request) => {
}),
]);
} else {
- throw new Error("Unhandled relevant event!");
+ return new Response(`Unhandled relevant event: ${event.type}`, {
+ status: 400,
+ });
}
} catch (error) {
await log({