cencori 1.7.4 → 1.7.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/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1812,8 +1812,12 @@ async function request(config, method, path, body, extraHeaders, options) {
|
|
|
1812
1812
|
});
|
|
1813
1813
|
if (!response.ok) {
|
|
1814
1814
|
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1815
|
-
const message = typeof errorData.error === "string" ? errorData.error : errorData.error?.message
|
|
1815
|
+
const message = typeof errorData.error === "string" ? errorData.error : errorData.error?.message ?? (typeof errorData.message === "string" ? errorData.message : null) ?? response.statusText;
|
|
1816
1816
|
const details = typeof errorData.error === "object" ? errorData.error : null;
|
|
1817
|
+
const topCode = typeof errorData.code === "string" ? errorData.code : null;
|
|
1818
|
+
const topRequestId = typeof errorData.request_id === "string" ? errorData.request_id : typeof errorData.requestId === "string" ? errorData.requestId : null;
|
|
1819
|
+
const topType = typeof errorData.type === "string" ? errorData.type : null;
|
|
1820
|
+
const topParam = typeof errorData.param === "string" ? errorData.param : null;
|
|
1817
1821
|
let retryAfterSeconds = parseRetryAfterSeconds(response.headers.get("Retry-After") ?? response.headers.get("retry-after"));
|
|
1818
1822
|
if (retryAfterSeconds == null) {
|
|
1819
1823
|
const secHint = details?.retry_after_seconds ?? errorData.retry_after_seconds ?? details?.retry_after ?? errorData.retry_after;
|
|
@@ -1826,7 +1830,7 @@ async function request(config, method, path, body, extraHeaders, options) {
|
|
|
1826
1830
|
}
|
|
1827
1831
|
}
|
|
1828
1832
|
}
|
|
1829
|
-
throw new CencoriEmbeddedApiError(message, response.status, details?.code ??
|
|
1833
|
+
throw new CencoriEmbeddedApiError(message, response.status, details?.code ?? topCode, details?.request_id ?? topRequestId ?? response.headers.get("X-Request-Id"), details?.type ?? topType, details?.param ?? topParam, retryAfterSeconds);
|
|
1830
1834
|
}
|
|
1831
1835
|
if (response.status === 204) return void 0;
|
|
1832
1836
|
return response.json();
|