@forge/llm 0.2.0-next.4 → 0.2.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/utils/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,UAAU,EAAoB,MAAM,WAAW,CAAC;AAE9F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQzC,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAE9D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/utils/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,UAAU,EAAoB,MAAM,WAAW,CAAC;AAE9F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQzC,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAE9D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB7E;AAYD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAMnE"}
|
|
@@ -23,16 +23,22 @@ async function checkResponseError(response) {
|
|
|
23
23
|
statusText,
|
|
24
24
|
traceId
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const structured = getStructuredForgeError(parsedBody);
|
|
27
|
+
if (structured) {
|
|
28
|
+
throw new errors_1.ForgeLlmAPIError(responseDetails, structured);
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
message: text_1.Text.error.unKnownError,
|
|
32
|
-
context: { responseText }
|
|
33
|
-
});
|
|
30
|
+
const unstructured = getUnstructuredForgeError(response, responseText);
|
|
31
|
+
throw new errors_1.ForgeLlmAPIError(responseDetails, unstructured);
|
|
34
32
|
}
|
|
35
33
|
exports.checkResponseError = checkResponseError;
|
|
34
|
+
function getStructuredForgeError(parsedBody) {
|
|
35
|
+
return parsedBody && isForgeError(parsedBody) ? parsedBody : undefined;
|
|
36
|
+
}
|
|
37
|
+
function getUnstructuredForgeError(response, responseText) {
|
|
38
|
+
const code = response.headers.get('forge-proxy-error') ?? errors_1.errorCodes.UNKNOWN_ERROR;
|
|
39
|
+
const message = responseText || text_1.Text.error.unKnownError;
|
|
40
|
+
return { code, message, context: {} };
|
|
41
|
+
}
|
|
36
42
|
function safeGetParsedBody(text) {
|
|
37
43
|
try {
|
|
38
44
|
return JSON.parse(text);
|