@spacelr/sdk 0.10.5 → 0.10.6
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 +16 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -310,18 +310,27 @@ var HttpClient = class {
|
|
|
310
310
|
}
|
|
311
311
|
throwHttpError(statusCode, body) {
|
|
312
312
|
const apiBody = body;
|
|
313
|
-
const message = apiBody.error?.message ?? `HTTP ${statusCode}`;
|
|
314
|
-
const code = apiBody.error?.code ?? `HTTP_${statusCode}`;
|
|
315
|
-
const details = apiBody.error?.details;
|
|
316
313
|
const flatBody = body;
|
|
314
|
+
const flatMessage = (() => {
|
|
315
|
+
const m = flatBody["message"];
|
|
316
|
+
if (typeof m === "string" && m.length > 0) return m;
|
|
317
|
+
if (Array.isArray(m)) {
|
|
318
|
+
const parts = m.filter((x) => typeof x === "string");
|
|
319
|
+
if (parts.length > 0) return parts.join("; ");
|
|
320
|
+
}
|
|
321
|
+
return void 0;
|
|
322
|
+
})();
|
|
323
|
+
const message = apiBody.error?.message ?? flatMessage ?? `HTTP ${statusCode}`;
|
|
324
|
+
const code = apiBody.error?.code ?? `HTTP_${statusCode}`;
|
|
325
|
+
const details = apiBody.error?.details ?? (flatMessage !== void 0 ? flatBody : void 0);
|
|
317
326
|
if (statusCode === 400 && flatBody["errorCode"] === "SEARCH_FILTER_REQUIRED") {
|
|
318
|
-
const
|
|
327
|
+
const flatMessage2 = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
|
|
319
328
|
const missingFields = Array.isArray(flatBody["missingFields"]) ? flatBody["missingFields"] : [];
|
|
320
|
-
throw new SpacelrSearchFilterRequiredError(
|
|
329
|
+
throw new SpacelrSearchFilterRequiredError(flatMessage2, { missingFields });
|
|
321
330
|
}
|
|
322
331
|
if (statusCode === 400 && flatBody["errorCode"] === "SCAN_LIMIT_EXCEEDED") {
|
|
323
|
-
const
|
|
324
|
-
throw new SpacelrScanLimitExceededError(
|
|
332
|
+
const flatMessage2 = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
|
|
333
|
+
throw new SpacelrScanLimitExceededError(flatMessage2);
|
|
325
334
|
}
|
|
326
335
|
if (statusCode === 401 || statusCode === 403) {
|
|
327
336
|
throw new SpacelrAuthError(message, statusCode, details);
|