npm package diff

Package: @forge/sql

Versions: 2.2.0 - 2.2.1-next.0

File: package/out/utils/error-handling.js

Index: package/out/utils/error-handling.js
===================================================================
--- package/out/utils/error-handling.js
+++ package/out/utils/error-handling.js
@@ -1,7 +1,8 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.checkResponseError = exports.isForgeError = void 0;
+const errorCodes_1 = require("../errorCodes");
 const errors_1 = require("../errors");
 function isForgeError(body) {
     if (typeof body === 'object' && body !== null) {
         if ('code' in body && 'message' in body) {
@@ -15,17 +16,18 @@
     if (response.ok) {
         return;
     }
     const responseText = await response.text();
+    const traceId = response.headers.get('x-b3-traceid') || response.headers.get('x-trace-id');
     const details = {
         status: response.status,
         statusText: response.statusText,
-        traceId: response.headers.get('x-trace-id')
+        traceId
     };
     try {
         const parsedBody = JSON.parse(responseText);
         if (isForgeError(parsedBody)) {
-            throw new errors_1.ForgeSQLAPIError(details, parsedBody, message);
+            throw new errors_1.ForgeSQLAPIError(details, parsedBody);
         }
     }
     catch (error) {
         if (error instanceof SyntaxError) {
@@ -33,7 +35,11 @@
         else {
             throw error;
         }
     }
-    throw new errors_1.ForgeSQLAPIUnknownError(details, responseText, message);
+    throw new errors_1.ForgeSQLAPIError(details, {
+        code: errorCodes_1.errorCodes.UNKNOWN_ERROR,
+        message: message || 'Unexpected error in Forge SQL API request',
+        context: { responseText }
+    });
 }
 exports.checkResponseError = checkResponseError;