@kayahr/edsm 1.1.0 → 2.0.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.
@@ -1,5 +1,5 @@
1
1
  import type { Id64 } from "../common.ts";
2
- import { EDSMException } from "../util.ts";
2
+ import { EDSMError } from "../util.ts";
3
3
  export declare const edsmBaseUrl = "https://www.edsm.net";
4
4
  /**
5
5
  * Request options for referencing a system via EDSM or Frontier ID instead of name. Needed when system name is not unique.
@@ -10,11 +10,11 @@ export interface SystemIdRequestOptions {
10
10
  /** The system ID64 if you seek for a duplicate system and want to force a specific ID. */
11
11
  systemId64?: Id64;
12
12
  }
13
- export declare class ServerException extends EDSMException {
13
+ export declare class ServerError extends EDSMError {
14
14
  readonly status: number;
15
15
  constructor(status: number, message: string);
16
16
  }
17
- export declare class APIException extends EDSMException {
17
+ export declare class APIError extends EDSMError {
18
18
  readonly status: number;
19
19
  constructor(status: number, message: string);
20
20
  }
@@ -3,19 +3,21 @@
3
3
  * See LICENSE.md for licensing information.
4
4
  */
5
5
  import { JSONStringify } from "json-with-bigint";
6
- import { EDSMException, jsonReviver } from "../util.js";
6
+ import { EDSMError, jsonReviver } from "../util.js";
7
7
  export const edsmBaseUrl = "https://www.edsm.net";
8
- export class ServerException extends EDSMException {
8
+ export class ServerError extends EDSMError {
9
9
  status;
10
10
  constructor(status, message) {
11
11
  super(message);
12
+ this.name = "ServerError";
12
13
  this.status = status;
13
14
  }
14
15
  }
15
- export class APIException extends EDSMException {
16
+ export class APIError extends EDSMError {
16
17
  status;
17
18
  constructor(status, message) {
18
19
  super(message);
20
+ this.name = "APIError";
19
21
  this.status = status;
20
22
  }
21
23
  }
@@ -33,13 +35,13 @@ export async function request(url, params = {}) {
33
35
  body: JSONStringify(params)
34
36
  });
35
37
  if (result.status !== 200) {
36
- throw new ServerException(result.status, result.statusText);
38
+ throw new ServerError(result.status, result.statusText);
37
39
  }
38
40
  const text = await result.text();
39
41
  const json = JSON.parse(text, jsonReviver);
40
42
  if (json.msgnum != null && json.msg != null) {
41
43
  if (json.msgnum < 100 || json.msgnum >= 200) {
42
- throw new APIException(json.msgnum, json.msg);
44
+ throw new APIError(json.msgnum, json.msg);
43
45
  }
44
46
  else {
45
47
  delete json.msgnum;
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/main/api/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,CAAC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAalD,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAC9B,MAAM,CAAS;IAE/B,YAAmB,MAAc,EAAE,OAAe;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAED,MAAM,OAAO,YAAa,SAAQ,aAAa;IAC3B,MAAM,CAAS;IAE/B,YAAmB,MAAc,EAAE,OAAe;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAOD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,GAAW,EAAE,SAAkC,EAAE;IAC9E,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,WAAW,IAAI,GAAG,EAAE,EAAE;QAChD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;KAC9B,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACxB,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,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OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2020 Klaus Reimer <k@ailis.de>
3
3
  * See LICENSE.md for licensing information.
4
4
  */
5
- import { NotFoundException } from "../util.js";
5
+ import { NotFoundError } from "../util.js";
6
6
  import { request } from "./common.js";
7
7
  /**
8
8
  * Returns the system bodies of the given star system.
@@ -15,7 +15,7 @@ import { request } from "./common.js";
15
15
  export async function getSystemBodies(systemName, ids) {
16
16
  const response = await request("api-system-v1/bodies", { systemName, ...ids });
17
17
  if (response == null) {
18
- throw new NotFoundException(`System not found: ${systemName}`);
18
+ throw new NotFoundError(`System not found: ${systemName}`);
19
19
  }
20
20
  return response;
21
21
  }
@@ -30,7 +30,7 @@ export async function getSystemBodies(systemName, ids) {
30
30
  export async function getSystemEstimatedValue(systemName, ids) {
31
31
  const response = await request("api-system-v1/estimated-value", { systemName, ...ids });
32
32
  if (response == null) {
33
- throw new NotFoundException(`System not found: ${systemName}`);
33
+ throw new NotFoundError(`System not found: ${systemName}`);
34
34
  }
35
35
  return response;
36
36
  }
@@ -45,7 +45,7 @@ export async function getSystemEstimatedValue(systemName, ids) {
45
45
  export async function getSystemStations(systemName, ids) {
46
46
  const response = await request("api-system-v1/stations", { systemName, ...ids });
47
47
  if (response == null) {
48
- throw new NotFoundException(`System not found: ${systemName}`);
48
+ throw new NotFoundError(`System not found: ${systemName}`);
49
49
  }
50
50
  return response;
51
51
  }
@@ -56,14 +56,14 @@ async function getStationDetails(detail, marketIdOrSystemName, stationName, para
56
56
  const marketId = marketIdOrSystemName;
57
57
  data = await request(url, { marketId });
58
58
  if (data == null) {
59
- throw new NotFoundException(`Market not found: ${marketId}`);
59
+ throw new NotFoundError(`Market not found: ${marketId}`);
60
60
  }
61
61
  }
62
62
  else {
63
63
  const systemName = marketIdOrSystemName;
64
64
  data = await request(url, { systemName, stationName, ...params });
65
65
  if (data == null) {
66
- throw new NotFoundException(`Station '${stationName}' in '${systemName}' not found`);
66
+ throw new NotFoundError(`Station '${stationName}' in '${systemName}' not found`);
67
67
  }
68
68
  }
69
69
  return data;
@@ -88,7 +88,7 @@ export async function getStationOutfitting(marketIdOrSystemName, stationName, pa
88
88
  export async function getSystemFactions(systemName, options) {
89
89
  const response = await request("api-system-v1/factions", { systemName, ...options });
90
90
  if (response == null) {
91
- throw new NotFoundException(`System not found: ${systemName}`);
91
+ throw new NotFoundError(`System not found: ${systemName}`);
92
92
  }
93
93
  return response;
94
94
  }
@@ -103,7 +103,7 @@ export async function getSystemFactions(systemName, options) {
103
103
  export async function getSystemTraffic(systemName, ids) {
104
104
  const response = await request("api-system-v1/traffic", { systemName, ...ids });
105
105
  if (response == null) {
106
- throw new NotFoundException(`System not found: ${systemName}`);
106
+ throw new NotFoundError(`System not found: ${systemName}`);
107
107
  }
108
108
  return response;
109
109
  }
@@ -118,7 +118,7 @@ export async function getSystemTraffic(systemName, ids) {
118
118
  export async function getSystemDeaths(systemName, ids) {
119
119
  const response = await request("api-system-v1/deaths", { systemName, ...ids });
120
120
  if (response == null) {
121
- throw new NotFoundException(`System not found: ${systemName}`);
121
+ throw new NotFoundError(`System not found: ${systemName}`);
122
122
  }
123
123
  return response;
124
124
  }
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/main/api/system.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAA+B,OAAO,EAAE,MAAM,aAAa,CAAC;AAuFnE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAAkB,EAAE,GAA8C;IACpG,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAuB,sBAAsB,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;IACrG,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,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,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;IACvG,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAiBD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAAkB,EAAE,GAA4B;IAClF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAuB,sBAAsB,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;IACrG,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2025 Klaus Reimer <k@ailis.de>
3
3
  * See LICENSE.md for licensing information.
4
4
  */
5
- import { NotFoundException } from "../util.js";
5
+ import { NotFoundError } from "../util.js";
6
6
  import { request } from "./common.js";
7
7
  /**
8
8
  * Returns information about the given system.
@@ -14,7 +14,7 @@ import { request } from "./common.js";
14
14
  export async function getSystem(systemName, options) {
15
15
  const system = await request("api-v1/system", { systemName, ...options });
16
16
  if (system == null) {
17
- throw new NotFoundException(`System not found: ${systemName}`);
17
+ throw new NotFoundError(`System not found: ${systemName}`);
18
18
  }
19
19
  return system;
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"systems.js","sourceRoot":"","sources":["../../../src/main/api/systems.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAA+B,OAAO,EAAE,MAAM,aAAa,CAAC;AAkGnE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAAkB,EAAE,OAA8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,OAAO,CAAC,qBAAqB,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAE,CAAC;AAC9E,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { type CommanderCreditsResponse, type CommanderInventoryResponse, type CommanderRanksResponse, type CreditsPeriod, getCommanderCredits, getCommanderInventory, getCommanderRanks, type InventoryType } from "./api/commander.ts";
2
- export { APIException, ServerException, type SystemIdRequestOptions } from "./api/common.ts";
2
+ export { APIError, ServerError, type SystemIdRequestOptions } from "./api/common.ts";
3
3
  export { type EDSMEvent, type EventResponse, getDiscardEvents, sendEvents } from "./api/journal.ts";
4
4
  export { type CommanderPositionOptions, type CommanderPositionResponse, type FlightLog, type FlightLogFilter, type FlightLogsResponse, getCommanderPosition, getFlightLogs, getSystemComment, getSystemComments, setSystemComment, type SystemCommentResponse, type SystemCommentsOptions, type SystemCommentsResponse } from "./api/logs.ts";
5
5
  export { type EliteServerStatusResponse, type EliteServerStatusType, getEliteServerStatus } from "./api/status.ts";
@@ -11,4 +11,4 @@ export { type Coordinates, type Id64, toUTCString } from "./common.ts";
11
11
  export { parsePowerPlayJSON, type PowerPlay, type PowerPlays } from "./powerplay.ts";
12
12
  export { type Commodity, type Outfitting, parseStationsJSON, type Ship, type Station, type StationBody, type StationControllingFaction, type Stations, type StationUpdateTime, type SystemStation } from "./stations.ts";
13
13
  export { type ControllingFaction, type EstimatedCoordinates, type Faction, parseSystemsJSON, type State, type System, type Systems, type TrendState } from "./systems.ts";
14
- export { IllegalStateException, NotFoundException } from "./util.ts";
14
+ export { IllegalStateError, NotFoundError } from "./util.ts";
package/lib/main/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md for licensing information.
4
4
  */
5
5
  export { getCommanderCredits, getCommanderInventory, getCommanderRanks } from "./api/commander.js";
6
- export { APIException, ServerException } from "./api/common.js";
6
+ export { APIError, ServerError } from "./api/common.js";
7
7
  export { getDiscardEvents, sendEvents } from "./api/journal.js";
8
8
  export { getCommanderPosition, getFlightLogs, getSystemComment, getSystemComments, setSystemComment } from "./api/logs.js";
9
9
  export { getEliteServerStatus } from "./api/status.js";
@@ -15,5 +15,5 @@ export { toUTCString } from "./common.js";
15
15
  export { parsePowerPlayJSON } from "./powerplay.js";
16
16
  export { parseStationsJSON } from "./stations.js";
17
17
  export { parseSystemsJSON } from "./systems.js";
18
- export { IllegalStateException, NotFoundException } from "./util.js";
18
+ export { IllegalStateError, NotFoundError } from "./util.js";
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAC8G,mBAAmB,EAAE,qBAAqB,EAC3J,iBAAiB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,eAAe,EAA+B,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAsC,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EACuH,oBAAoB,EAC9I,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAEvE,MAAM,eAAe,CAAC;AACvB,OAAO,EAA8D,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACnH,OAAO,EACiB,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,uBAAuB,EACzI,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAGzD,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAC6B,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAE1F,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACiE,QAAQ,EAAE,MAAM,EAAkB,eAAe,EAExH,MAAM,aAAa,CAAC;AACrB,OAAO,EAA4B,cAAc,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAA+B,WAAW,EAAE,MAAM,aAAa,CAAC;AACv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+D,gBAAgB,EACrF,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Base class for all exceptions. Automatically corrects its prototype and name.
3
3
  */
4
- export declare abstract class EDSMException extends Error {
4
+ export declare abstract class EDSMError extends Error {
5
+ /** @inheritdoc */
6
+ name: string;
5
7
  /**
6
8
  * Creates a new exception.
7
9
  *
@@ -11,10 +13,14 @@ export declare abstract class EDSMException extends Error {
11
13
  constructor(message: string, options?: ErrorOptions);
12
14
  }
13
15
  /** Thrown when state is illegal. */
14
- export declare class IllegalStateException extends EDSMException {
16
+ export declare class IllegalStateError extends EDSMError {
17
+ /** @inheritdoc */
18
+ name: string;
15
19
  }
16
20
  /** Thrown when some resource was not found. */
17
- export declare class NotFoundException extends EDSMException {
21
+ export declare class NotFoundError extends EDSMError {
22
+ /** @inheritdoc */
23
+ name: string;
18
24
  }
19
25
  /**
20
26
  * Helper function to iterate over the array entries of the given stream. The stream must be a JSON file with an array
package/lib/main/util.js CHANGED
@@ -5,7 +5,9 @@
5
5
  /**
6
6
  * Base class for all exceptions. Automatically corrects its prototype and name.
7
7
  */
8
- export class EDSMException extends Error {
8
+ export class EDSMError extends Error {
9
+ /** @inheritdoc */
10
+ name = "EDSMError";
9
11
  /**
10
12
  * Creates a new exception.
11
13
  *
@@ -14,15 +16,18 @@ export class EDSMException extends Error {
14
16
  */
15
17
  constructor(message, options) {
16
18
  super(message, options);
17
- this.name = this.constructor.name;
18
19
  Object.setPrototypeOf(this, new.target.prototype);
19
20
  }
20
21
  }
21
22
  /** Thrown when state is illegal. */
22
- export class IllegalStateException extends EDSMException {
23
+ export class IllegalStateError extends EDSMError {
24
+ /** @inheritdoc */
25
+ name = "IllegalStateError";
23
26
  }
24
27
  /** Thrown when some resource was not found. */
25
- export class NotFoundException extends EDSMException {
28
+ export class NotFoundError extends EDSMError {
29
+ /** @inheritdoc */
30
+ name = "NotFoundError";
26
31
  }
27
32
  /**
28
33
  * Helper function to iterate over the lines of a data stream.
@@ -65,7 +70,7 @@ export async function* parseJSONArray(stream) {
65
70
  inData = true;
66
71
  }
67
72
  else {
68
- throw new IllegalStateException(`Expected array start but got: ${line}`);
73
+ throw new IllegalStateError(`Expected array start but got: ${line}`);
69
74
  }
70
75
  }
71
76
  else {
@@ -96,7 +101,7 @@ export function jsonReviver(key, value, context) {
96
101
  return BigInt(source);
97
102
  }
98
103
  else if (String(value) !== source && /^[-+]?\d+$/.test(source)) {
99
- throw new IllegalStateException(`Value of property '${key}' looks like a bigint (${source}) but was parsed as an imprecise number (${value})`);
104
+ throw new IllegalStateError(`Value of property '${key}' looks like a bigint (${source}) but was parsed as an imprecise number (${value})`);
100
105
  }
101
106
  }
102
107
  return value;
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/main/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,OAAgB,aAAc,SAAQ,KAAK;IAC7C;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,OAAsB;QACtD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACJ;AAED,oCAAoC;AACpC,MAAM,OAAO,qBAAsB,SAAQ,aAAa;CAAG;AAE3D,+CAA+C;AAC/C,MAAM,OAAO,iBAAkB,SAAQ,aAAa;CAAG;AAEvD;;;;;GAKG;AACH,KAAK,SAAU,CAAC,CAAA,UAAU,CAAC,MAAiC;IACxD,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EA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/package",
2
+ "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@kayahr/edsm",
4
- "version": "1.1.0",
4
+ "version": "2.0.0",
5
5
  "type": "module",
6
6
  "description": "Typescript types and utility functions for the Elite Dangerous Star Map (EDSM) API",
7
7
  "keywords": [
@@ -64,19 +64,20 @@
64
64
  "prepare": "run clean build"
65
65
  },
66
66
  "devDependencies": {
67
- "@kayahr/assert": "1.3.2",
68
- "@kayahr/cspell": "9.2.2-bundle.1",
69
- "@kayahr/npm-utils": "1.1.1",
67
+ "@kayahr/assert": "1.4.1",
68
+ "@kayahr/cspell": "9.7.0-bundle.1",
69
+ "@kayahr/npm-utils": "1.1.2",
70
70
  "@kayahr/ntest": "1.3.0",
71
- "@kayahr/oxlint-config": "1.11.0",
72
- "@kayahr/ts-json-schema-generator": "2.4.0-bundle.1",
73
- "@kayahr/typedoc": "0.28.14-bundle.2",
74
- "@types/node": "24.10.0",
75
- "ajv": "8.17.1",
71
+ "@kayahr/oxlint-config": "1.31.0",
72
+ "@kayahr/ts-json-schema-generator": "2.4.0-bundle.2",
73
+ "@kayahr/typedoc": "0.28.18-bundle.1",
74
+ "@types/node": "25.5.0",
75
+ "ajv": "8.18.0",
76
76
  "fetch-mock": "12.6.0",
77
- "typescript": "5.9.3"
77
+ "signal-polyfill": "0.2.2",
78
+ "typescript": "6.0.2"
78
79
  },
79
80
  "dependencies": {
80
- "json-with-bigint": "^3.4.4"
81
+ "json-with-bigint": "^3.5.8"
81
82
  }
82
83
  }
@@ -6,7 +6,7 @@
6
6
  import { JSONStringify } from "json-with-bigint";
7
7
 
8
8
  import type { Id64 } from "../common.ts";
9
- import { EDSMException, jsonReviver } from "../util.ts";
9
+ import { EDSMError, jsonReviver } from "../util.ts";
10
10
 
11
11
  export const edsmBaseUrl = "https://www.edsm.net";
12
12
 
@@ -21,20 +21,22 @@ export interface SystemIdRequestOptions {
21
21
  systemId64?: Id64;
22
22
  }
23
23
 
24
- export class ServerException extends EDSMException {
24
+ export class ServerError extends EDSMError {
25
25
  public readonly status: number;
26
26
 
27
27
  public constructor(status: number, message: string) {
28
28
  super(message);
29
+ this.name = "ServerError";
29
30
  this.status = status;
30
31
  }
31
32
  }
32
33
 
33
- export class APIException extends EDSMException {
34
+ export class APIError extends EDSMError {
34
35
  public readonly status: number;
35
36
 
36
37
  public constructor(status: number, message: string) {
37
38
  super(message);
39
+ this.name = "APIError";
38
40
  this.status = status;
39
41
  }
40
42
  }
@@ -58,13 +60,13 @@ export async function request<T>(url: string, params: Record<string, unknown> =
58
60
  body: JSONStringify(params)
59
61
  });
60
62
  if (result.status !== 200) {
61
- throw new ServerException(result.status, result.statusText);
63
+ throw new ServerError(result.status, result.statusText);
62
64
  }
63
65
  const text = await result.text();
64
66
  const json = JSON.parse(text, jsonReviver) as T & MessageResult;
65
67
  if (json.msgnum != null && json.msg != null) {
66
68
  if (json.msgnum < 100 || json.msgnum >= 200) {
67
- throw new APIException(json.msgnum, json.msg);
69
+ throw new APIError(json.msgnum, json.msg);
68
70
  } else {
69
71
  delete json.msgnum;
70
72
  delete json.msg;
@@ -6,7 +6,7 @@
6
6
  import type { SystemBody } from "../bodies.ts";
7
7
  import type { Id64 } from "../common.ts";
8
8
  import type { Commodity, Outfitting, Ship, SystemStation } from "../stations.ts";
9
- import { NotFoundException } from "../util.ts";
9
+ import { NotFoundError } from "../util.ts";
10
10
  import { type SystemIdRequestOptions, request } from "./common.ts";
11
11
 
12
12
  export interface BodyScanValue {
@@ -105,7 +105,7 @@ export interface StationOutfittingResponse {
105
105
  export async function getSystemBodies(systemName: string, ids?: { systemId?: number, systemId64?: Id64 }): Promise<SystemBodiesResponse> {
106
106
  const response = await request<SystemBodiesResponse>("api-system-v1/bodies", { systemName, ...ids });
107
107
  if (response == null) {
108
- throw new NotFoundException(`System not found: ${systemName}`);
108
+ throw new NotFoundError(`System not found: ${systemName}`);
109
109
  }
110
110
  return response;
111
111
  }
@@ -121,7 +121,7 @@ export async function getSystemBodies(systemName: string, ids?: { systemId?: num
121
121
  export async function getSystemEstimatedValue(systemName: string, ids?: SystemIdRequestOptions): Promise<SystemEstimatedValueResponse> {
122
122
  const response = await request<SystemEstimatedValueResponse>("api-system-v1/estimated-value", { systemName, ...ids });
123
123
  if (response == null) {
124
- throw new NotFoundException(`System not found: ${systemName}`);
124
+ throw new NotFoundError(`System not found: ${systemName}`);
125
125
  }
126
126
  return response;
127
127
  }
@@ -137,7 +137,7 @@ export async function getSystemEstimatedValue(systemName: string, ids?: SystemId
137
137
  export async function getSystemStations(systemName: string, ids?: SystemIdRequestOptions): Promise<SystemStationsResponse> {
138
138
  const response = await request<SystemStationsResponse>("api-system-v1/stations", { systemName, ...ids });
139
139
  if (response == null) {
140
- throw new NotFoundException(`System not found: ${systemName}`);
140
+ throw new NotFoundError(`System not found: ${systemName}`);
141
141
  }
142
142
  return response;
143
143
  }
@@ -149,13 +149,13 @@ async function getStationDetails<T>(detail: string, marketIdOrSystemName: number
149
149
  const marketId = marketIdOrSystemName;
150
150
  data = await request<T>(url, { marketId });
151
151
  if (data == null) {
152
- throw new NotFoundException(`Market not found: ${marketId}`);
152
+ throw new NotFoundError(`Market not found: ${marketId}`);
153
153
  }
154
154
  } else {
155
155
  const systemName = marketIdOrSystemName;
156
156
  data = await request<T>(url, { systemName, stationName, ...params });
157
157
  if (data == null) {
158
- throw new NotFoundException(`Station '${stationName}' in '${systemName}' not found`);
158
+ throw new NotFoundError(`Station '${stationName}' in '${systemName}' not found`);
159
159
  }
160
160
  }
161
161
  return data;
@@ -288,7 +288,7 @@ export interface SystemFactionsResponse {
288
288
  export async function getSystemFactions(systemName: string, options?: SystemFactionsOptions): Promise<SystemFactionsResponse> {
289
289
  const response = await request<SystemFactionsResponse>("api-system-v1/factions", { systemName, ...options });
290
290
  if (response == null) {
291
- throw new NotFoundException(`System not found: ${systemName}`);
291
+ throw new NotFoundError(`System not found: ${systemName}`);
292
292
  }
293
293
  return response;
294
294
  }
@@ -324,7 +324,7 @@ export interface SystemTrafficResponse {
324
324
  export async function getSystemTraffic(systemName: string, ids?: SystemIdRequestOptions): Promise<SystemTrafficResponse> {
325
325
  const response = await request<SystemTrafficResponse>("api-system-v1/traffic", { systemName, ...ids });
326
326
  if (response == null) {
327
- throw new NotFoundException(`System not found: ${systemName}`);
327
+ throw new NotFoundError(`System not found: ${systemName}`);
328
328
  }
329
329
  return response;
330
330
  }
@@ -355,7 +355,7 @@ export interface SystemDeathsResponse {
355
355
  export async function getSystemDeaths(systemName: string, ids?: SystemIdRequestOptions): Promise<SystemDeathsResponse> {
356
356
  const response = await request<SystemDeathsResponse>("api-system-v1/deaths", { systemName, ...ids });
357
357
  if (response == null) {
358
- throw new NotFoundException(`System not found: ${systemName}`);
358
+ throw new NotFoundError(`System not found: ${systemName}`);
359
359
  }
360
360
  return response;
361
361
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { Coordinates, Id64 } from "../common.ts";
7
- import { NotFoundException } from "../util.ts";
7
+ import { NotFoundError } from "../util.ts";
8
8
  import { type SystemIdRequestOptions, request } from "./common.ts";
9
9
 
10
10
  /**
@@ -113,7 +113,7 @@ export interface SystemRequestOptions extends SystemIdRequestOptions, SystemRequ
113
113
  export async function getSystem(systemName: string, options?: SystemRequestOptions): Promise<SystemResponse> {
114
114
  const system = await request<SystemResponse>("api-v1/system", { systemName, ...options });
115
115
  if (system == null) {
116
- throw new NotFoundException(`System not found: ${systemName}`);
116
+ throw new NotFoundError(`System not found: ${systemName}`);
117
117
  }
118
118
  return system;
119
119
  }
package/src/main/index.ts CHANGED
@@ -7,7 +7,7 @@ export {
7
7
  type CommanderCreditsResponse, type CommanderInventoryResponse, type CommanderRanksResponse, type CreditsPeriod, getCommanderCredits, getCommanderInventory,
8
8
  getCommanderRanks, type InventoryType
9
9
  } from "./api/commander.ts";
10
- export { APIException, ServerException, type SystemIdRequestOptions } from "./api/common.ts";
10
+ export { APIError, ServerError, type SystemIdRequestOptions } from "./api/common.ts";
11
11
  export { type EDSMEvent, type EventResponse, getDiscardEvents, sendEvents } from "./api/journal.ts";
12
12
  export {
13
13
  type CommanderPositionOptions, type CommanderPositionResponse, type FlightLog, type FlightLogFilter, type FlightLogsResponse, getCommanderPosition,
@@ -39,4 +39,4 @@ export {
39
39
  export {
40
40
  type ControllingFaction, type EstimatedCoordinates, type Faction, parseSystemsJSON, type State, type System, type Systems, type TrendState
41
41
  } from "./systems.ts";
42
- export { IllegalStateException, NotFoundException } from "./util.ts";
42
+ export { IllegalStateError, NotFoundError } from "./util.ts";
package/src/main/util.ts CHANGED
@@ -6,7 +6,10 @@
6
6
  /**
7
7
  * Base class for all exceptions. Automatically corrects its prototype and name.
8
8
  */
9
- export abstract class EDSMException extends Error {
9
+ export abstract class EDSMError extends Error {
10
+ /** @inheritdoc */
11
+ public override name = "EDSMError";
12
+
10
13
  /**
11
14
  * Creates a new exception.
12
15
  *
@@ -15,16 +18,21 @@ export abstract class EDSMException extends Error {
15
18
  */
16
19
  public constructor(message: string, options?: ErrorOptions) {
17
20
  super(message, options);
18
- this.name = this.constructor.name;
19
21
  Object.setPrototypeOf(this, new.target.prototype);
20
22
  }
21
23
  }
22
24
 
23
25
  /** Thrown when state is illegal. */
24
- export class IllegalStateException extends EDSMException {}
26
+ export class IllegalStateError extends EDSMError {
27
+ /** @inheritdoc */
28
+ public override name = "IllegalStateError";
29
+ }
25
30
 
26
31
  /** Thrown when some resource was not found. */
27
- export class NotFoundException extends EDSMException {}
32
+ export class NotFoundError extends EDSMError {
33
+ /** @inheritdoc */
34
+ public override name = "NotFoundError";
35
+ }
28
36
 
29
37
  /**
30
38
  * Helper function to iterate over the lines of a data stream.
@@ -67,7 +75,7 @@ export async function *parseJSONArray<T>(stream: AsyncIterable<Uint8Array>): Asy
67
75
  if (line === "[") {
68
76
  inData = true;
69
77
  } else {
70
- throw new IllegalStateException(`Expected array start but got: ${line}`);
78
+ throw new IllegalStateError(`Expected array start but got: ${line}`);
71
79
  }
72
80
  } else {
73
81
  if (line === "]") {
@@ -96,7 +104,7 @@ export function jsonReviver(key: string, value: unknown, context?: { source: str
96
104
  if (key === "id64" || key === "systemId64") {
97
105
  return BigInt(source);
98
106
  } else if (String(value) !== source && /^[-+]?\d+$/.test(source)) {
99
- throw new IllegalStateException(`Value of property '${key}' looks like a bigint (${source}) but was parsed as an imprecise number (${value})`);
107
+ throw new IllegalStateError(`Value of property '${key}' looks like a bigint (${source}) but was parsed as an imprecise number (${value})`);
100
108
  }
101
109
  }
102
110
  return value;