Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix(api): handle zoderrors earlier
Gergő Móricz26d87bd09972
diff --git a/apps/api/src/index.ts b/apps/api/src/index.tsindex a30005c4e..583701584 100644--- a/apps/api/src/index.ts+++ b/apps/api/src/index.ts@@ -190,27 +190,31 @@ if (cluster.isMaster) {res.send({ isProduction: global.isProduction });});- Sentry.setupExpressErrorHandler(app);-- app.use((err: unknown, req: Request<{}, ErrorResponse, undefined>, res: ResponseWithSentry<ErrorResponse>, next: NextFunction) => {+ app.use((err: unknown, req: Request<{}, ErrorResponse, undefined>, res: Response<ErrorResponse>, next: NextFunction) => {if (err instanceof ZodError) {res.status(400).json({ success: false, error: "Bad Request", details: err.errors });} else {- const id = res.sentry ?? uuidv4();- let verbose = JSON.stringify(err);- if (verbose === "{}") {- if (err instanceof Error) {- verbose = JSON.stringify({- message: err.message,- name: err.name,- stack: err.stack,- });- }- }+ next(err);+ }+ });++ Sentry.setupExpressErrorHandler(app);- Logger.error("Error occurred in request! (" + req.path + ") -- ID " + id + " -- " + verbose);- res.status(500).json({ success: false, error: "An unexpected error occurred. Please contact [email protected] for help. Your exception ID is " + id });+ app.use((err: unknown, req: Request<{}, ErrorResponse, undefined>, res: ResponseWithSentry<ErrorResponse>, next: NextFunction) => {+ const id = res.sentry ?? uuidv4();+ let verbose = JSON.stringify(err);+ if (verbose === "{}") {+ if (err instanceof Error) {+ verbose = JSON.stringify({+ message: err.message,+ name: err.name,+ stack: err.stack,+ });+ }}++ Logger.error("Error occurred in request! (" + req.path + ") -- ID " + id + " -- " + verbose);+ res.status(500).json({ success: false, error: "An unexpected error occurred. Please contact [email protected] for help. Your exception ID is " + id });});Logger.info(`Worker ${process.pid} started`);