@remote-app/transmission-client 0.22.0 → 0.23.0

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.cjs CHANGED
@@ -4,10 +4,11 @@ let base_64 = require("base-64");
4
4
 
5
5
  //#region src/error.ts
6
6
  var HTTPError = class extends Error {
7
- constructor(status, message) {
7
+ constructor(status, message, body) {
8
8
  super(message);
9
9
  this.status = status;
10
10
  this.message = message;
11
+ this.body = body;
11
12
  this.name = "HTTPError";
12
13
  }
13
14
  };
@@ -59,8 +60,9 @@ var TransmissionClient = class {
59
60
  body: JSON.stringify({ method: "session-stats" })
60
61
  }));
61
62
  if (response.status !== 409) {
62
- if (!response.ok) throw new HTTPError(response.status, response.statusText);
63
- throw new HTTPError(response.status, "Expected Transmission session negotiation response");
63
+ const body = await response.text();
64
+ if (!response.ok) throw new HTTPError(response.status, response.statusText, body);
65
+ throw new HTTPError(response.status, "Expected Transmission session negotiation response", body);
64
66
  }
65
67
  const nextSession = response.headers.get("x-transmission-session-id");
66
68
  if (!nextSession) throw new HTTPError(409, "Missing x-transmission-session-id header");
@@ -83,7 +85,10 @@ var TransmissionClient = class {
83
85
  await this.ensureSession();
84
86
  return await this.request(req, false);
85
87
  }
86
- if (!response.ok) throw new HTTPError(response.status, response.statusText);
88
+ if (!response.ok) {
89
+ const body = await response.text();
90
+ throw new HTTPError(response.status, response.statusText, body);
91
+ }
87
92
  const text = await response.text();
88
93
  let json;
89
94
  try {
package/dist/index.d.cts CHANGED
@@ -337,7 +337,8 @@ type ResponseForRequest<Req extends AnyRequest> = Req extends RequestForMethod<i
337
337
  declare class HTTPError extends Error {
338
338
  readonly status: number;
339
339
  readonly message: string;
340
- constructor(status: number, message: string);
340
+ readonly body?: string | undefined;
341
+ constructor(status: number, message: string, body?: string | undefined);
341
342
  }
342
343
  declare class TransmissionError extends Error {
343
344
  readonly message: string;
package/dist/index.d.mts CHANGED
@@ -337,7 +337,8 @@ type ResponseForRequest<Req extends AnyRequest> = Req extends RequestForMethod<i
337
337
  declare class HTTPError extends Error {
338
338
  readonly status: number;
339
339
  readonly message: string;
340
- constructor(status: number, message: string);
340
+ readonly body?: string | undefined;
341
+ constructor(status: number, message: string, body?: string | undefined);
341
342
  }
342
343
  declare class TransmissionError extends Error {
343
344
  readonly message: string;
package/dist/index.mjs CHANGED
@@ -3,10 +3,11 @@ import { encode } from "base-64";
3
3
 
4
4
  //#region src/error.ts
5
5
  var HTTPError = class extends Error {
6
- constructor(status, message) {
6
+ constructor(status, message, body) {
7
7
  super(message);
8
8
  this.status = status;
9
9
  this.message = message;
10
+ this.body = body;
10
11
  this.name = "HTTPError";
11
12
  }
12
13
  };
@@ -58,8 +59,9 @@ var TransmissionClient = class {
58
59
  body: JSON.stringify({ method: "session-stats" })
59
60
  }));
60
61
  if (response.status !== 409) {
61
- if (!response.ok) throw new HTTPError(response.status, response.statusText);
62
- throw new HTTPError(response.status, "Expected Transmission session negotiation response");
62
+ const body = await response.text();
63
+ if (!response.ok) throw new HTTPError(response.status, response.statusText, body);
64
+ throw new HTTPError(response.status, "Expected Transmission session negotiation response", body);
63
65
  }
64
66
  const nextSession = response.headers.get("x-transmission-session-id");
65
67
  if (!nextSession) throw new HTTPError(409, "Missing x-transmission-session-id header");
@@ -82,7 +84,10 @@ var TransmissionClient = class {
82
84
  await this.ensureSession();
83
85
  return await this.request(req, false);
84
86
  }
85
- if (!response.ok) throw new HTTPError(response.status, response.statusText);
87
+ if (!response.ok) {
88
+ const body = await response.text();
89
+ throw new HTTPError(response.status, response.statusText, body);
90
+ }
86
91
  const text = await response.text();
87
92
  let json;
88
93
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remote-app/transmission-client",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Transmission RPC client",
5
5
  "keywords": [
6
6
  "transmission",