@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 CHANGED
@@ -354,18 +354,27 @@ var HttpClient = class {
354
354
  }
355
355
  throwHttpError(statusCode, body) {
356
356
  const apiBody = body;
357
- const message = apiBody.error?.message ?? `HTTP ${statusCode}`;
358
- const code = apiBody.error?.code ?? `HTTP_${statusCode}`;
359
- const details = apiBody.error?.details;
360
357
  const flatBody = body;
358
+ const flatMessage = (() => {
359
+ const m = flatBody["message"];
360
+ if (typeof m === "string" && m.length > 0) return m;
361
+ if (Array.isArray(m)) {
362
+ const parts = m.filter((x) => typeof x === "string");
363
+ if (parts.length > 0) return parts.join("; ");
364
+ }
365
+ return void 0;
366
+ })();
367
+ const message = apiBody.error?.message ?? flatMessage ?? `HTTP ${statusCode}`;
368
+ const code = apiBody.error?.code ?? `HTTP_${statusCode}`;
369
+ const details = apiBody.error?.details ?? (flatMessage !== void 0 ? flatBody : void 0);
361
370
  if (statusCode === 400 && flatBody["errorCode"] === "SEARCH_FILTER_REQUIRED") {
362
- const flatMessage = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
371
+ const flatMessage2 = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
363
372
  const missingFields = Array.isArray(flatBody["missingFields"]) ? flatBody["missingFields"] : [];
364
- throw new SpacelrSearchFilterRequiredError(flatMessage, { missingFields });
373
+ throw new SpacelrSearchFilterRequiredError(flatMessage2, { missingFields });
365
374
  }
366
375
  if (statusCode === 400 && flatBody["errorCode"] === "SCAN_LIMIT_EXCEEDED") {
367
- const flatMessage = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
368
- throw new SpacelrScanLimitExceededError(flatMessage);
376
+ const flatMessage2 = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
377
+ throw new SpacelrScanLimitExceededError(flatMessage2);
369
378
  }
370
379
  if (statusCode === 401 || statusCode === 403) {
371
380
  throw new SpacelrAuthError(message, statusCode, details);