@lastbrain/ai-ui-core 1.0.18 → 1.0.19
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.
|
@@ -12,7 +12,7 @@ async function fetchWithRetry(url, options, retryConfig) {
|
|
|
12
12
|
const response = await fetch(url, options);
|
|
13
13
|
if (!response.ok) {
|
|
14
14
|
const errorData = await response.json().catch(() => ({}));
|
|
15
|
-
const error = new Error(errorData
|
|
15
|
+
const error = new Error(JSON.stringify(errorData) || `HTTP ${response.status}`);
|
|
16
16
|
error.status = response.status;
|
|
17
17
|
error.response = { status: response.status };
|
|
18
18
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeError.d.ts","sourceRoot":"","sources":["../../src/errors/normalizeError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"normalizeError.d.ts","sourceRoot":"","sources":["../../src/errors/normalizeError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,eAAe,CA0G1D"}
|
|
@@ -31,6 +31,13 @@ export function normalizeError(error) {
|
|
|
31
31
|
status,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
if (status === 402) {
|
|
35
|
+
return {
|
|
36
|
+
code: ErrorCode.INSUFFICIENT_TOKENS,
|
|
37
|
+
message: error?.message || "Insufficient balance",
|
|
38
|
+
status,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
34
41
|
if (status === 503) {
|
|
35
42
|
return {
|
|
36
43
|
code: ErrorCode.PROVIDER_DOWN,
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ async function fetchWithRetry<T>(
|
|
|
38
38
|
if (!response.ok) {
|
|
39
39
|
const errorData = await response.json().catch(() => ({}));
|
|
40
40
|
const error: any = new Error(
|
|
41
|
-
errorData
|
|
41
|
+
JSON.stringify(errorData) || `HTTP ${response.status}`
|
|
42
42
|
);
|
|
43
43
|
error.status = response.status;
|
|
44
44
|
error.response = { status: response.status };
|
|
@@ -45,6 +45,14 @@ export function normalizeError(error: any): NormalizedError {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
if (status === 402) {
|
|
49
|
+
return {
|
|
50
|
+
code: ErrorCode.INSUFFICIENT_TOKENS,
|
|
51
|
+
message: error?.message || "Insufficient balance",
|
|
52
|
+
status,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
if (status === 503) {
|
|
49
57
|
return {
|
|
50
58
|
code: ErrorCode.PROVIDER_DOWN,
|