Nick: fixed error handling for v0 scrape

This commit is contained in:
Nicolas 2024-09-20 18:35:30 -04:00
parent 0690cfeaad
commit 3fc5ce17d2
1 changed files with 11 additions and 3 deletions

View File

@ -285,11 +285,19 @@ export async function scrapeController(req: Request, res: Response) {
} catch (error) { } catch (error) {
Sentry.captureException(error); Sentry.captureException(error);
Logger.error(error); Logger.error(error);
return res.status(500).json({ if (typeof error === "string" && error.startsWith("{\"type\":\"all\",")) {
error: return res.status(500).json({
success: false,
error: "All scraping methods failed for URL: " + req.body.url,
details: JSON.parse(error).errors as string[],
});
} else {
return res.status(500).json({
error:
typeof error === "string" typeof error === "string"
? error ? error
: error?.message ?? "Internal Server Error", : error?.message ?? "Internal Server Error",
}); });
}
} }
} }