From 88d776f3929ec6b4d5317e6e1f49ca1a6e14b0dc Mon Sep 17 00:00:00 2001
From: Thuc Pham <51660321+thucpn@users.noreply.github.com>
Date: Thu, 20 Feb 2025 16:33:34 +0700
Subject: [PATCH] fix: enhance error message in llamacloud (#1672)

---
 .changeset/young-pans-pump.md          | 5 +++++
 packages/llamaindex/src/cloud/utils.ts | 5 +++++
 2 files changed, 10 insertions(+)
 create mode 100644 .changeset/young-pans-pump.md

diff --git a/.changeset/young-pans-pump.md b/.changeset/young-pans-pump.md
new file mode 100644
index 000000000..c238898ba
--- /dev/null
+++ b/.changeset/young-pans-pump.md
@@ -0,0 +1,5 @@
+---
+"llamaindex": patch
+---
+
+fix: enhance error message in llamacloud
diff --git a/packages/llamaindex/src/cloud/utils.ts b/packages/llamaindex/src/cloud/utils.ts
index 4c38b246d..3ebc65d5a 100644
--- a/packages/llamaindex/src/cloud/utils.ts
+++ b/packages/llamaindex/src/cloud/utils.ts
@@ -31,6 +31,11 @@ export function initService({ apiKey, baseUrl }: ClientParams = {}) {
     request.headers.set("Authorization", `Bearer ${token}`);
     return request;
   });
+  client.interceptors.error.use((error) => {
+    throw new Error(
+      `LlamaCloud API request failed. Error details: ${JSON.stringify(error)}`,
+    );
+  });
   if (!token) {
     throw new Error(
       "API Key is required for LlamaCloudIndex. Please pass the apiKey parameter",
-- 
GitLab