Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

stringify-error

Gaurav Chadha5eefc3c2b22f
diff --git a/apps/api/src/controllers/v1/extract-status.ts b/apps/api/src/controllers/v1/extract-status.ts
index 4a61cdc7a..c232d0f1c 100644
--- a/apps/api/src/controllers/v1/extract-status.ts
+++ b/apps/api/src/controllers/v1/extract-status.ts
@@ -116,7 +116,13 @@ export async function extractStatusController(
success: status === "failed" ? false : true,
data,
status,
- error: typeof extract?.error === "string" ? extract.error : undefined,
+ error: (() => {
+ if (typeof extract?.error === "string") return extract.error;
+ if (extract?.error && typeof extract.error === "object") {
+ return extract.error.message || extract.error.error || JSON.stringify(extract.error);
+ }
+ return undefined;
+ })(),
expiresAt: (await getExtractExpiry(req.params.jobId)).toISOString(),
steps: extract?.showSteps ? extract.steps : undefined,
llmUsage: extract?.showLLMUsage ? extract.llmUsage : undefined,
diff --git a/apps/api/src/controllers/v2/extract-status.ts b/apps/api/src/controllers/v2/extract-status.ts
index f640a14b0..f68081d54 100644
--- a/apps/api/src/controllers/v2/extract-status.ts
+++ b/apps/api/src/controllers/v2/extract-status.ts
@@ -116,7 +116,13 @@ export async function extractStatusController(
success: status === "failed" ? false : true,
data,
status,
- error: typeof extract?.error === "string" ? extract.error : undefined,
+ error: (() => {
+ if (typeof extract?.error === "string") return extract.error;
+ if (extract?.error && typeof extract.error === "object") {
+ return extract.error.message || extract.error.error || JSON.stringify(extract.error);
+ }
+ return undefined;
+ })(),
expiresAt: (await getExtractExpiry(req.params.jobId)).toISOString(),
steps: extract?.showSteps ? extract.steps : undefined,
llmUsage: extract?.showLLMUsage ? extract.llmUsage : undefined,