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.

add try catch

Steven Teydb01bc94156c
diff --git a/apps/web/app/api/links/crawl/bitly/[domain]/[key]/route.ts b/apps/web/app/api/links/crawl/bitly/[domain]/[key]/route.ts
index bc2b1703c1..bb649c2e48 100644
--- a/apps/web/app/api/links/crawl/bitly/[domain]/[key]/route.ts
+++ b/apps/web/app/api/links/crawl/bitly/[domain]/[key]/route.ts
@@ -60,24 +60,31 @@ export const GET = async (_req: NextRequest, { params }) => {
`[Bitly] Creating link ${newLink.shortLink} -> ${newLink.url}`,
);
- waitUntil(
- conn.execute(
- "INSERT INTO Link (id, projectId, userId, domain, `key`, url, shortLink, archived, folderId, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
- [
- newLink.id,
- newLink.projectId,
- newLink.userId,
- newLink.domain,
- newLink.key,
- newLink.url,
- newLink.shortLink,
- newLink.archived,
- newLink.folderId,
- newLink.createdAt,
- newLink.updatedAt,
- ],
- ),
- );
+ try {
+ waitUntil(
+ conn.execute(
+ "INSERT INTO Link (id, projectId, userId, domain, `key`, url, shortLink, archived, folderId, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ [
+ newLink.id,
+ newLink.projectId,
+ newLink.userId,
+ newLink.domain,
+ newLink.key,
+ newLink.url,
+ newLink.shortLink,
+ newLink.archived,
+ newLink.folderId,
+ newLink.createdAt,
+ newLink.updatedAt,
+ ],
+ ),
+ );
+ } catch (error) {
+ console.error(
+ `[Bitly] Error creating link ${newLink.shortLink} -> ${newLink.url}`,
+ error,
+ );
+ }
return NextResponse.redirect(sanitizedUrl, {
headers: DUB_HEADERS,