tsarr 2.7.3 → 2.7.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/service.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAED,eAAO,MAAM,sBAAsB,UAA0D,CAAC;AAE9F,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,EAAE,CAM5E;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,EACnC,SAAS,EAAE,WAAW,EAAE,uDA+MzB"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/service.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAED,eAAO,MAAM,sBAAsB,UAA0D,CAAC;AAE9F,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,EAAE,CAM5E;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,EACnC,SAAS,EAAE,WAAW,EAAE,uDAsMzB"}
package/dist/cli/index.js CHANGED
@@ -5409,6 +5409,12 @@ function buildServiceCommand(serviceName, description, clientFactory, resources)
5409
5409
  const raw = await action.run(client2, resolvedArgs);
5410
5410
  if (raw?.error !== undefined) {
5411
5411
  const err = raw.error;
5412
+ const networkMsg = classifyNetworkError(err, serviceName);
5413
+ if (networkMsg) {
5414
+ consola.error(`${networkMsg}
5415
+ Run \`tsarr doctor\` to diagnose.`);
5416
+ process.exit(1);
5417
+ }
5412
5418
  const status = err?.status ?? raw?.response?.status;
5413
5419
  if (status === 401) {
5414
5420
  const authHint = serviceName === "qbittorrent" ? "Check your username and password." : `Check your API key.
@@ -5416,18 +5422,6 @@ Run \`tsarr config init\` or set TSARR_${serviceName.toUpperCase()}_API_KEY`;
5416
5422
  consola.error(`Unauthorized. ${authHint}`);
5417
5423
  } else if (status === 404) {
5418
5424
  consola.error("Not found.");
5419
- } else if (!status && err?.code) {
5420
- const code = err.code;
5421
- if (code === "ConnectionRefused" || code === "ECONNREFUSED") {
5422
- consola.error(`Connection refused. Is ${serviceName} running?
5423
- Run \`tsarr doctor\` to diagnose.`);
5424
- } else if (code === "ConnectionReset" || code === "ECONNRESET") {
5425
- consola.error(`Connection reset. ${serviceName} may have crashed.
5426
- Run \`tsarr doctor\` to diagnose.`);
5427
- } else {
5428
- consola.error(`${err?.message ?? `Network error (${code})`}
5429
- Run \`tsarr doctor\` to diagnose.`);
5430
- }
5431
5425
  } else {
5432
5426
  consola.error(err?.title ?? err?.message ?? `API error (${status ?? "unknown"})`);
5433
5427
  }
@@ -5525,12 +5519,42 @@ Run \`tsarr doctor\` to diagnose.`);
5525
5519
  } else if (error instanceof TsarrError) {
5526
5520
  consola.error(`Error: ${error.message}`);
5527
5521
  } else if (error instanceof Error) {
5528
- consola.error(error.message);
5522
+ const networkMsg = classifyNetworkError(error, serviceName);
5523
+ if (networkMsg) {
5524
+ consola.error(`${networkMsg}
5525
+ Run \`tsarr doctor\` to diagnose.`);
5526
+ } else {
5527
+ consola.error(error.message);
5528
+ }
5529
5529
  } else {
5530
5530
  consola.error("An unexpected error occurred.");
5531
5531
  }
5532
5532
  process.exit(1);
5533
5533
  }
5534
+ function classifyNetworkError(error, serviceName) {
5535
+ if (!error || typeof error !== "object")
5536
+ return null;
5537
+ const err = error;
5538
+ const cause = err.cause;
5539
+ const code = cause?.code ?? err.code;
5540
+ const msg = err.message ?? "";
5541
+ if (code === "ECONNREFUSED" || code === "ConnectionRefused") {
5542
+ return `Connection refused. Is ${serviceName} running?`;
5543
+ }
5544
+ if (code === "ENOTFOUND") {
5545
+ return `Host not found for ${serviceName}. Check the URL.`;
5546
+ }
5547
+ if (code === "ECONNRESET" || code === "ConnectionReset") {
5548
+ return `Connection reset. ${serviceName} may have crashed.`;
5549
+ }
5550
+ if (code === "ETIMEDOUT") {
5551
+ return `Connection timed out for ${serviceName}.`;
5552
+ }
5553
+ if (msg === "fetch failed" || msg.includes("fetch failed")) {
5554
+ return `Unable to reach ${serviceName}${cause?.message ? `: ${cause.message}` : ""}`;
5555
+ }
5556
+ return null;
5557
+ }
5534
5558
  var COMMAND_OUTPUT_COLUMNS;
5535
5559
  var init_service = __esm(() => {
5536
5560
  init_dist();
@@ -21319,8 +21343,10 @@ var init_doctor = __esm(() => {
21319
21343
  const status = await client9.getSystemStatus();
21320
21344
  if (status?.error !== undefined) {
21321
21345
  const err = status.error;
21322
- const cause = err?.code ? { code: err.code } : undefined;
21323
- throw Object.assign(new Error(err?.message ?? err?.code ?? "Unknown API error"), cause ? { cause } : {});
21346
+ const code = err?.cause?.code ?? err?.code;
21347
+ const cause = code ? { code } : undefined;
21348
+ const message = err?.cause?.message ?? err?.message ?? err?.code ?? "Unknown API error";
21349
+ throw Object.assign(new Error(message), cause ? { cause } : {});
21324
21350
  }
21325
21351
  const version = extractVersion(service, status) ?? "?";
21326
21352
  if (version === "?") {
@@ -21764,7 +21790,7 @@ init_dist();
21764
21790
  // package.json
21765
21791
  var package_default = {
21766
21792
  name: "tsarr",
21767
- version: "2.7.3",
21793
+ version: "2.7.5",
21768
21794
  author: "Robbe Verhelst",
21769
21795
  repository: {
21770
21796
  type: "git",
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsarr",
3
- "version": "2.7.3",
3
+ "version": "2.7.5",
4
4
  "author": "Robbe Verhelst",
5
5
  "repository": {
6
6
  "type": "git",
Binary file