recappi 0.1.62 → 0.1.63

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
@@ -19508,14 +19508,27 @@ var RecappiApiClient = class {
19508
19508
  }
19509
19509
  async request(method, pathname, body, opts = {}) {
19510
19510
  const token = requireToken(this.auth);
19511
- const response = await this.fetchImpl(new URL(pathname, this.auth.origin), {
19512
- method,
19513
- headers: {
19514
- authorization: `Bearer ${token}`,
19515
- ...opts.headers
19516
- },
19517
- ...body ? { body } : {}
19518
- });
19511
+ let response;
19512
+ try {
19513
+ response = await this.fetchImpl(new URL(pathname, this.auth.origin), {
19514
+ method,
19515
+ headers: {
19516
+ authorization: `Bearer ${token}`,
19517
+ ...opts.headers
19518
+ },
19519
+ ...body ? { body } : {}
19520
+ });
19521
+ } catch (error51) {
19522
+ if (error51 instanceof RecappiCliError) throw error51;
19523
+ throw cliError(
19524
+ "cloud.http_error",
19525
+ `Recappi Cloud request failed: ${transportErrorMessage(error51)}`,
19526
+ {
19527
+ retryable: true,
19528
+ hint: `Check your network connection and Recappi Cloud origin (${this.auth.origin}), then retry.`
19529
+ }
19530
+ );
19531
+ }
19519
19532
  if (!response.ok && !(opts.allowAuthFailure && (response.status === 401 || response.status === 403))) {
19520
19533
  const message = await responseMessage(response);
19521
19534
  throw new RecappiCliError(describeHttpError(response.status, message));
@@ -19523,6 +19536,10 @@ var RecappiApiClient = class {
19523
19536
  return response;
19524
19537
  }
19525
19538
  };
19539
+ function transportErrorMessage(error51) {
19540
+ if (error51 instanceof Error && error51.message) return error51.message;
19541
+ return String(error51 || "network request failed");
19542
+ }
19526
19543
  async function parseJson(response) {
19527
19544
  try {
19528
19545
  return await response.json();