@netmind/arena-cli 0.35.0 → 0.35.2

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
@@ -392,6 +392,8 @@ async function api(path3, opts = {}) {
392
392
  const suffix = retryAfter !== void 0 ? ` (retry after ${retryAfter}s)` : "";
393
393
  const err = new Error(`API error ${res.status}: ${msg}${suffix}`);
394
394
  if (typeof data?.code === "string") err.code = data.code;
395
+ if (typeof data?.hint === "string") err.hint = data.hint;
396
+ if (typeof data?.docs === "string") err.docs = data.docs;
395
397
  err.status = res.status;
396
398
  if (retryAfter !== void 0) err.retryAfter = retryAfter;
397
399
  throw err;
@@ -439,15 +441,21 @@ function isJsonMode(argv = process.argv) {
439
441
  }
440
442
  function printError(error) {
441
443
  const message = error instanceof Error ? error.message : String(error);
444
+ const detail = error ?? {};
445
+ const hint = typeof detail.hint === "string" ? detail.hint : void 0;
446
+ const docs = typeof detail.docs === "string" ? detail.docs : void 0;
442
447
  if (!isJsonMode()) {
443
448
  console.error(`error: ${message}`);
449
+ if (hint) console.error(`hint: ${hint}`);
450
+ if (docs) console.error(`docs: ${docs}`);
444
451
  return;
445
452
  }
446
- const detail = error ?? {};
447
453
  const out = { error: message };
448
454
  if (typeof detail.status === "number") out.status = detail.status;
449
455
  if (typeof detail.code === "string") out.code = detail.code;
450
456
  if (typeof detail.retryAfter === "number") out.retryAfter = detail.retryAfter;
457
+ if (hint) out.hint = hint;
458
+ if (docs) out.docs = docs;
451
459
  console.log(JSON.stringify(out));
452
460
  }
453
461
  function printSuccess(msg) {
@@ -508,7 +516,13 @@ var loginCmd = new Command2("login").description("Log in with an existing API ke
508
516
  headers: { Authorization: `Bearer ${opts.apiKey}` }
509
517
  });
510
518
  if (!res.ok) {
511
- throw new Error(`Invalid API key (status ${res.status})`);
519
+ const body = await res.json().catch(() => ({}));
520
+ throw Object.assign(new Error(`Invalid API key (status ${res.status})`), {
521
+ status: res.status,
522
+ ...typeof body.code === "string" ? { code: body.code } : {},
523
+ ...typeof body.hint === "string" ? { hint: body.hint } : {},
524
+ ...typeof body.docs === "string" ? { docs: body.docs } : {}
525
+ });
512
526
  }
513
527
  const profile = await res.json();
514
528
  saveCredentials({