[object Object]

← back to Ken

Ken: surface real Kalshi API error body (was '[object Object]') + method/path in kalshiFetch errors — reveals the 410 order-failure reason

a3aff5e26e02aeefcdb9aa6de0023e6a1392cd5b · 2026-07-15 13:05:48 -0700 · Steve Abrams

Files touched

Diff

commit a3aff5e26e02aeefcdb9aa6de0023e6a1392cd5b
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Jul 15 13:05:48 2026 -0700

    Ken: surface real Kalshi API error body (was '[object Object]') + method/path in kalshiFetch errors — reveals the 410 order-failure reason
---
 kalshi-dash/server.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kalshi-dash/server.js b/kalshi-dash/server.js
index 55070e4..7175dde 100644
--- a/kalshi-dash/server.js
+++ b/kalshi-dash/server.js
@@ -531,8 +531,9 @@ async function kalshiFetch(method, apiPath, body = null) {
   }
 
   if (!response.ok) {
-    const errMsg = data?.message || data?.error || data?.raw || `HTTP ${response.status}`;
-    throw new Error(`Kalshi API error (${response.status}): ${errMsg}`);
+    const errBody = data?.message || data?.error || data?.raw || data || `HTTP ${response.status}`;
+    const errMsg = typeof errBody === 'string' ? errBody : JSON.stringify(errBody);
+    throw new Error(`Kalshi API error (${response.status}) ${method} ${apiPath}: ${errMsg}`);
   }
 
   return data;
@@ -555,8 +556,9 @@ async function kalshiPublicFetch(method, apiPath) {
   }
 
   if (!response.ok) {
-    const errMsg = data?.message || data?.error || data?.raw || `HTTP ${response.status}`;
-    throw new Error(`Kalshi API error (${response.status}): ${errMsg}`);
+    const errBody = data?.message || data?.error || data?.raw || data || `HTTP ${response.status}`;
+    const errMsg = typeof errBody === 'string' ? errBody : JSON.stringify(errBody);
+    throw new Error(`Kalshi API error (${response.status}) ${method} ${apiPath}: ${errMsg}`);
   }
 
   return data;

← 2066e75 Ken: FIX no-trades root cause — Kalshi API renamed price fie  ·  back to Ken  ·  (newest)