@superlinked/sie-sdk 0.3.1 → 0.3.3

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.d.cts CHANGED
@@ -732,7 +732,7 @@ declare class SIEClient {
732
732
  private detectEndpointType;
733
733
  }
734
734
 
735
- declare const SDK_VERSION = "0.3.1";
735
+ declare const SDK_VERSION = "0.3.3";
736
736
 
737
737
  /**
738
738
  * Helpers for converting SIE encode results to plain JavaScript types.
package/dist/index.d.ts CHANGED
@@ -732,7 +732,7 @@ declare class SIEClient {
732
732
  private detectEndpointType;
733
733
  }
734
734
 
735
- declare const SDK_VERSION = "0.3.1";
735
+ declare const SDK_VERSION = "0.3.3";
736
736
 
737
737
  /**
738
738
  * Helpers for converting SIE encode results to plain JavaScript types.
package/dist/index.js CHANGED
@@ -380,20 +380,35 @@ async function throwIfModelLoadFailed(response, model) {
380
380
  }
381
381
  async function handleError(response, gpu) {
382
382
  const { status } = response;
383
- let errorBody = {};
384
- try {
385
- errorBody = await response.json();
386
- } catch {
383
+ const detail = await getErrorDetail(response.clone());
384
+ let code;
385
+ let message;
386
+ if (detail) {
387
+ const c = detail.code;
388
+ code = typeof c === "string" ? c : void 0;
389
+ const m = detail.message;
390
+ message = typeof m === "string" ? m : JSON.stringify(detail);
391
+ } else {
392
+ try {
393
+ const data = await response.json();
394
+ if (typeof data.detail === "string") {
395
+ code = typeof data.code === "string" ? data.code : void 0;
396
+ message = data.detail;
397
+ } else if (typeof data.message === "string") {
398
+ code = typeof data.code === "string" ? data.code : void 0;
399
+ message = data.message;
400
+ } else {
401
+ code = typeof data.code === "string" ? data.code : void 0;
402
+ message = response.statusText;
403
+ }
404
+ } catch {
405
+ code = void 0;
406
+ message = response.statusText;
407
+ }
387
408
  }
388
- const code = errorBody.code ?? "UNKNOWN";
389
- const message = errorBody.detail ?? response.statusText;
390
409
  if (status === HTTP_ACCEPTED) {
391
- const retryAfter = response.headers.get("Retry-After");
392
- throw new ProvisioningError(
393
- message,
394
- gpu,
395
- retryAfter ? Number.parseInt(retryAfter, 10) * 1e3 : void 0
396
- );
410
+ const retryAfter = getRetryAfter2(response);
411
+ throw new ProvisioningError(message, gpu, retryAfter);
397
412
  }
398
413
  if (status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_CLIENT_ERROR_MAX) {
399
414
  throw new RequestError(message, code, status);
@@ -514,7 +529,7 @@ function parseCapacityInfo(data, gpuFilter) {
514
529
  }
515
530
 
516
531
  // src/version.ts
517
- var SDK_VERSION = "0.3.1";
532
+ var SDK_VERSION = "0.3.3";
518
533
 
519
534
  // src/client.ts
520
535
  function sleep(ms) {