feat(sentry): add error handles to try-catch blocks

This commit is contained in:
Gergo Moricz
2024-08-22 03:55:40 +02:00
parent e78d2af1f0
commit 0cdf41587e
8 changed files with 23 additions and 0 deletions
+3
View File
@@ -10,6 +10,7 @@ import { isUrlBlocked } from "../scraper/WebScraper/utils/blocklist";
import { v4 as uuidv4 } from "uuid";
import { Logger } from "../lib/logger";
import { getScrapeQueue, scrapeQueueEvents } from "../services/queue-service";
import * as Sentry from "@sentry/node";
export async function searchHelper(
jobId: string,
@@ -154,6 +155,7 @@ export async function searchController(req: Request, res: Response) {
return res.status(402).json({ error: "Insufficient credits" });
}
} catch (error) {
Sentry.captureException(error);
Logger.error(error);
return res.status(500).json({ error: "Internal server error" });
}
@@ -184,6 +186,7 @@ export async function searchController(req: Request, res: Response) {
});
return res.status(result.returnCode).json(result);
} catch (error) {
Sentry.captureException(error);
Logger.error(error);
return res.status(500).json({ error: error.message });
}