@dxos/errors 0.8.4-main.7ace549 → 0.8.4-main.937b3ca

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.
@@ -3,14 +3,14 @@ var BaseError = class _BaseError extends Error {
3
3
  /**
4
4
  * Primary way of defining new error classes.
5
5
  * Extended class may specialize constructor for required context params.
6
- * @param code - Error code.
6
+ * @param name - Error name.
7
7
  * @param message - Default error message.
8
8
  */
9
- static extend(code, message) {
9
+ static extend(name, message) {
10
10
  return class ExtendedError extends _BaseError {
11
- static code = code;
11
+ static name = name;
12
12
  static is(error) {
13
- return typeof error === "object" && error !== null && "code" in error && error.code === code;
13
+ return typeof error === "object" && error !== null && "name" in error && error.name === name;
14
14
  }
15
15
  static wrap(options) {
16
16
  const wrapFn = (error) => {
@@ -28,7 +28,7 @@ var BaseError = class _BaseError extends Error {
28
28
  return wrapFn;
29
29
  }
30
30
  constructor(options) {
31
- super(code, {
31
+ super(name, {
32
32
  message: options?.message ?? message,
33
33
  ...options
34
34
  });
@@ -36,41 +36,40 @@ var BaseError = class _BaseError extends Error {
36
36
  };
37
37
  }
38
38
  // NOTE: Errors go through odd transformations and the private fields seem to break.
39
- code;
39
+ name;
40
40
  context;
41
- constructor(code, options) {
41
+ constructor(name, options) {
42
42
  super(options?.message, {
43
43
  cause: options?.cause
44
44
  });
45
- this.code = code;
45
+ this.name = name;
46
46
  this.context = options?.context ?? {};
47
47
  Object.setPrototypeOf(this, new.target.prototype);
48
48
  }
49
- get name() {
50
- return this.code;
51
- }
52
49
  /** Fallback message. */
53
50
  get message() {
54
51
  return this.constructor.name;
55
52
  }
56
53
  // For effect error matching.
57
54
  get _tag() {
58
- return this.code;
55
+ return this.name;
59
56
  }
60
57
  };
61
58
 
62
59
  // src/errors.ts
63
- var ApiError = class extends BaseError.extend("API", "API error") {
60
+ var ApiError = class extends BaseError.extend("ApiError", "API error") {
61
+ };
62
+ var SystemError = class extends BaseError.extend("SystemError", "System error") {
64
63
  };
65
- var SystemError = class extends BaseError.extend("SYSTEM", "System error") {
64
+ var InternalError = class extends BaseError.extend("InternalError", "Internal error") {
66
65
  };
67
- var InternalError = class extends BaseError.extend("INTERNAL", "Internal error") {
66
+ var TimeoutError = class extends BaseError.extend("TimeoutError", "Timeout") {
68
67
  };
69
- var TimeoutError = class extends BaseError.extend("TIMEOUT", "Timeout") {
68
+ var AbortedError = class extends BaseError.extend("AbortedError", "Aborted") {
70
69
  };
71
- var AbortedError = class extends BaseError.extend("ABORTED", "Aborted") {
70
+ var NotImplementedError = class extends BaseError.extend("NotImplementedError", "Not implemented") {
72
71
  };
73
- var NotImplementedError = class extends BaseError.extend("NOT_IMPLEMENTED", "Not implemented") {
72
+ var RuntimeServiceError = class extends BaseError.extend("RuntimeServiceError", "Runtime service error") {
74
73
  };
75
74
  export {
76
75
  AbortedError,
@@ -78,6 +77,7 @@ export {
78
77
  BaseError,
79
78
  InternalError,
80
79
  NotImplementedError,
80
+ RuntimeServiceError,
81
81
  SystemError,
82
82
  TimeoutError
83
83
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/base.ts", "../../../src/errors.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Options for creating a BaseError.\n */\nexport type BaseErrorOptions = ErrorOptions & {\n /**\n * Override base message.\n */\n message?: string;\n\n /**\n * Structured details about the error.\n */\n context?: Record<string, unknown>;\n};\n\n/**\n * Base class for all DXOS errors.\n */\nexport class BaseError<Code extends string = string> extends Error {\n /**\n * Primary way of defining new error classes.\n * Extended class may specialize constructor for required context params.\n * @param code - Error code.\n * @param message - Default error message.\n */\n static extend<Code extends string = string>(code: Code, message?: string) {\n return class ExtendedError extends BaseError<Code> {\n static code = code;\n\n static is(error: unknown): error is BaseError {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code;\n }\n\n static wrap(\n options?: Omit<BaseErrorOptions, 'cause'> & { ifTypeDiffers?: boolean },\n ): (error: unknown) => ExtendedError {\n const wrapFn = (error: unknown) => {\n if (options?.ifTypeDiffers === true && this.is(error)) {\n return error as ExtendedError;\n }\n const newError: ExtendedError = new this({ message, ...options, cause: error });\n Error.captureStackTrace(newError, wrapFn); // Position stack-trace to start from the caller of `wrap`.\n return newError;\n };\n return wrapFn;\n }\n\n constructor(options?: BaseErrorOptions) {\n super(code, { message: options?.message ?? message, ...options });\n }\n };\n }\n\n // NOTE: Errors go through odd transformations and the private fields seem to break.\n code: Code;\n context: Record<string, unknown>;\n\n constructor(code: Code, options?: BaseErrorOptions) {\n super(options?.message, { cause: options?.cause });\n\n this.code = code;\n this.context = options?.context ?? {};\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n override get name() {\n return this.code;\n }\n\n /** Fallback message. */\n override get message() {\n return this.constructor.name;\n }\n\n // For effect error matching.\n get _tag(): Code {\n return this.code;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError } from './base';\n\nexport class ApiError extends BaseError.extend('API', 'API error') {}\n\nexport class SystemError extends BaseError.extend('SYSTEM', 'System error') {}\n\nexport class InternalError extends BaseError.extend('INTERNAL', 'Internal error') {}\n\nexport class TimeoutError extends BaseError.extend('TIMEOUT', 'Timeout') {}\n\nexport class AbortedError extends BaseError.extend('ABORTED', 'Aborted') {}\n\nexport class NotImplementedError extends BaseError.extend('NOT_IMPLEMENTED', 'Not implemented') {}\n"],
5
- "mappings": ";AAsBO,IAAMA,YAAN,MAAMA,mBAAgDC,MAAAA;;;;;;;EAO3D,OAAOC,OAAqCC,MAAYC,SAAkB;AACxE,WAAO,MAAMC,sBAAsBL,WAAAA;MACjC,OAAOG,OAAOA;MAEd,OAAOG,GAAGC,OAAoC;AAC5C,eAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,UAAUA,SAASA,MAAMJ,SAASA;MAC1F;MAEA,OAAOK,KACLC,SACmC;AACnC,cAAMC,SAAS,CAACH,UAAAA;AACd,cAAIE,SAASE,kBAAkB,QAAQ,KAAKL,GAAGC,KAAAA,GAAQ;AACrD,mBAAOA;UACT;AACA,gBAAMK,WAA0B,IAAI,KAAK;YAAER;YAAS,GAAGK;YAASI,OAAON;UAAM,CAAA;AAC7EN,gBAAMa,kBAAkBF,UAAUF,MAAAA;AAClC,iBAAOE;QACT;AACA,eAAOF;MACT;MAEA,YAAYD,SAA4B;AACtC,cAAMN,MAAM;UAAEC,SAASK,SAASL,WAAWA;UAAS,GAAGK;QAAQ,CAAA;MACjE;IACF;EACF;;EAGAN;EACAY;EAEA,YAAYZ,MAAYM,SAA4B;AAClD,UAAMA,SAASL,SAAS;MAAES,OAAOJ,SAASI;IAAM,CAAA;AAEhD,SAAKV,OAAOA;AACZ,SAAKY,UAAUN,SAASM,WAAW,CAAC;AACpCC,WAAOC,eAAe,MAAM,WAAWC,SAAS;EAClD;EAEA,IAAaC,OAAO;AAClB,WAAO,KAAKhB;EACd;;EAGA,IAAaC,UAAU;AACrB,WAAO,KAAK,YAAYe;EAC1B;;EAGA,IAAIC,OAAa;AACf,WAAO,KAAKjB;EACd;AACF;;;AC5EO,IAAMkB,WAAN,cAAuBC,UAAUC,OAAO,OAAO,WAAA,EAAA;AAAc;AAE7D,IAAMC,cAAN,cAA0BF,UAAUC,OAAO,UAAU,cAAA,EAAA;AAAiB;AAEtE,IAAME,gBAAN,cAA4BH,UAAUC,OAAO,YAAY,gBAAA,EAAA;AAAmB;AAE5E,IAAMG,eAAN,cAA2BJ,UAAUC,OAAO,WAAW,SAAA,EAAA;AAAY;AAEnE,IAAMI,eAAN,cAA2BL,UAAUC,OAAO,WAAW,SAAA,EAAA;AAAY;AAEnE,IAAMK,sBAAN,cAAkCN,UAAUC,OAAO,mBAAmB,iBAAA,EAAA;AAAoB;",
6
- "names": ["BaseError", "Error", "extend", "code", "message", "ExtendedError", "is", "error", "wrap", "options", "wrapFn", "ifTypeDiffers", "newError", "cause", "captureStackTrace", "context", "Object", "setPrototypeOf", "prototype", "name", "_tag", "ApiError", "BaseError", "extend", "SystemError", "InternalError", "TimeoutError", "AbortedError", "NotImplementedError"]
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Options for creating a BaseError.\n */\nexport type BaseErrorOptions = ErrorOptions & {\n /**\n * Override base message.\n */\n message?: string;\n\n /**\n * Structured details about the error.\n */\n context?: Record<string, unknown>;\n};\n\n/**\n * Base class for all DXOS errors.\n */\nexport class BaseError<Name extends string = string> extends Error {\n /**\n * Primary way of defining new error classes.\n * Extended class may specialize constructor for required context params.\n * @param name - Error name.\n * @param message - Default error message.\n */\n static extend<Name extends string = string>(name: Name, message?: string) {\n return class ExtendedError extends BaseError<Name> {\n static override name: Name = name;\n\n static is(error: unknown): error is BaseError {\n return typeof error === 'object' && error !== null && 'name' in error && error.name === name;\n }\n\n static wrap(\n options?: Omit<BaseErrorOptions, 'cause'> & { ifTypeDiffers?: boolean },\n ): (error: unknown) => ExtendedError {\n const wrapFn = (error: unknown) => {\n if (options?.ifTypeDiffers === true && this.is(error)) {\n return error as ExtendedError;\n }\n const newError: ExtendedError = new this({ message, ...options, cause: error });\n Error.captureStackTrace(newError, wrapFn); // Position stack-trace to start from the caller of `wrap`.\n return newError;\n };\n return wrapFn;\n }\n\n constructor(options?: BaseErrorOptions) {\n super(name, { message: options?.message ?? message, ...options });\n }\n };\n }\n\n // NOTE: Errors go through odd transformations and the private fields seem to break.\n override name: Name;\n context: Record<string, unknown>;\n\n constructor(name: Name, options?: BaseErrorOptions) {\n super(options?.message, { cause: options?.cause });\n\n this.name = name;\n this.context = options?.context ?? {};\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** Fallback message. */\n override get message() {\n return this.constructor.name;\n }\n\n // For effect error matching.\n get _tag(): Name {\n return this.name;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError } from './base';\n\nexport class ApiError extends BaseError.extend('ApiError', 'API error') {}\n\nexport class SystemError extends BaseError.extend('SystemError', 'System error') {}\n\nexport class InternalError extends BaseError.extend('InternalError', 'Internal error') {}\n\nexport class TimeoutError extends BaseError.extend('TimeoutError', 'Timeout') {}\n\nexport class AbortedError extends BaseError.extend('AbortedError', 'Aborted') {}\n\nexport class NotImplementedError extends BaseError.extend('NotImplementedError', 'Not implemented') {}\n\nexport class RuntimeServiceError extends BaseError.extend('RuntimeServiceError', 'Runtime service error') {}\n"],
5
+ "mappings": ";AAsBO,IAAMA,YAAN,MAAMA,mBAAgDC,MAAAA;;;;;;;EAO3D,OAAOC,OAAqCC,MAAYC,SAAkB;AACxE,WAAO,MAAMC,sBAAsBL,WAAAA;MACjC,OAAgBG,OAAaA;MAE7B,OAAOG,GAAGC,OAAoC;AAC5C,eAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,UAAUA,SAASA,MAAMJ,SAASA;MAC1F;MAEA,OAAOK,KACLC,SACmC;AACnC,cAAMC,SAAS,CAACH,UAAAA;AACd,cAAIE,SAASE,kBAAkB,QAAQ,KAAKL,GAAGC,KAAAA,GAAQ;AACrD,mBAAOA;UACT;AACA,gBAAMK,WAA0B,IAAI,KAAK;YAAER;YAAS,GAAGK;YAASI,OAAON;UAAM,CAAA;AAC7EN,gBAAMa,kBAAkBF,UAAUF,MAAAA;AAClC,iBAAOE;QACT;AACA,eAAOF;MACT;MAEA,YAAYD,SAA4B;AACtC,cAAMN,MAAM;UAAEC,SAASK,SAASL,WAAWA;UAAS,GAAGK;QAAQ,CAAA;MACjE;IACF;EACF;;EAGSN;EACTY;EAEA,YAAYZ,MAAYM,SAA4B;AAClD,UAAMA,SAASL,SAAS;MAAES,OAAOJ,SAASI;IAAM,CAAA;AAEhD,SAAKV,OAAOA;AACZ,SAAKY,UAAUN,SAASM,WAAW,CAAC;AACpCC,WAAOC,eAAe,MAAM,WAAWC,SAAS;EAClD;;EAGA,IAAad,UAAU;AACrB,WAAO,KAAK,YAAYD;EAC1B;;EAGA,IAAIgB,OAAa;AACf,WAAO,KAAKhB;EACd;AACF;;;ACxEO,IAAMiB,WAAN,cAAuBC,UAAUC,OAAO,YAAY,WAAA,EAAA;AAAc;AAElE,IAAMC,cAAN,cAA0BF,UAAUC,OAAO,eAAe,cAAA,EAAA;AAAiB;AAE3E,IAAME,gBAAN,cAA4BH,UAAUC,OAAO,iBAAiB,gBAAA,EAAA;AAAmB;AAEjF,IAAMG,eAAN,cAA2BJ,UAAUC,OAAO,gBAAgB,SAAA,EAAA;AAAY;AAExE,IAAMI,eAAN,cAA2BL,UAAUC,OAAO,gBAAgB,SAAA,EAAA;AAAY;AAExE,IAAMK,sBAAN,cAAkCN,UAAUC,OAAO,uBAAuB,iBAAA,EAAA;AAAoB;AAE9F,IAAMM,sBAAN,cAAkCP,UAAUC,OAAO,uBAAuB,uBAAA,EAAA;AAA0B;",
6
+ "names": ["BaseError", "Error", "extend", "name", "message", "ExtendedError", "is", "error", "wrap", "options", "wrapFn", "ifTypeDiffers", "newError", "cause", "captureStackTrace", "context", "Object", "setPrototypeOf", "prototype", "_tag", "ApiError", "BaseError", "extend", "SystemError", "InternalError", "TimeoutError", "AbortedError", "NotImplementedError", "RuntimeServiceError"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/base.ts":{"bytes":7183,"imports":[],"format":"esm"},"src/errors.ts":{"bytes":2213,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"}],"format":"esm"},"src/index.ts":{"bytes":523,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4645},"dist/lib/browser/index.mjs":{"imports":[],"exports":["AbortedError","ApiError","BaseError","InternalError","NotImplementedError","SystemError","TimeoutError"],"entryPoint":"src/index.ts","inputs":{"src/base.ts":{"bytesInOutput":1594},"src/index.ts":{"bytesInOutput":0},"src/errors.ts":{"bytesInOutput":491}},"bytes":2276}}}
1
+ {"inputs":{"src/base.ts":{"bytes":7022,"imports":[],"format":"esm"},"src/errors.ts":{"bytes":2648,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"}],"format":"esm"},"src/index.ts":{"bytes":523,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4800},"dist/lib/browser/index.mjs":{"imports":[],"exports":["AbortedError","ApiError","BaseError","InternalError","NotImplementedError","RuntimeServiceError","SystemError","TimeoutError"],"entryPoint":"src/index.ts","inputs":{"src/base.ts":{"bytesInOutput":1553},"src/index.ts":{"bytesInOutput":0},"src/errors.ts":{"bytesInOutput":630}},"bytes":2397}}}
@@ -5,14 +5,14 @@ var BaseError = class _BaseError extends Error {
5
5
  /**
6
6
  * Primary way of defining new error classes.
7
7
  * Extended class may specialize constructor for required context params.
8
- * @param code - Error code.
8
+ * @param name - Error name.
9
9
  * @param message - Default error message.
10
10
  */
11
- static extend(code, message) {
11
+ static extend(name, message) {
12
12
  return class ExtendedError extends _BaseError {
13
- static code = code;
13
+ static name = name;
14
14
  static is(error) {
15
- return typeof error === "object" && error !== null && "code" in error && error.code === code;
15
+ return typeof error === "object" && error !== null && "name" in error && error.name === name;
16
16
  }
17
17
  static wrap(options) {
18
18
  const wrapFn = (error) => {
@@ -30,7 +30,7 @@ var BaseError = class _BaseError extends Error {
30
30
  return wrapFn;
31
31
  }
32
32
  constructor(options) {
33
- super(code, {
33
+ super(name, {
34
34
  message: options?.message ?? message,
35
35
  ...options
36
36
  });
@@ -38,41 +38,40 @@ var BaseError = class _BaseError extends Error {
38
38
  };
39
39
  }
40
40
  // NOTE: Errors go through odd transformations and the private fields seem to break.
41
- code;
41
+ name;
42
42
  context;
43
- constructor(code, options) {
43
+ constructor(name, options) {
44
44
  super(options?.message, {
45
45
  cause: options?.cause
46
46
  });
47
- this.code = code;
47
+ this.name = name;
48
48
  this.context = options?.context ?? {};
49
49
  Object.setPrototypeOf(this, new.target.prototype);
50
50
  }
51
- get name() {
52
- return this.code;
53
- }
54
51
  /** Fallback message. */
55
52
  get message() {
56
53
  return this.constructor.name;
57
54
  }
58
55
  // For effect error matching.
59
56
  get _tag() {
60
- return this.code;
57
+ return this.name;
61
58
  }
62
59
  };
63
60
 
64
61
  // src/errors.ts
65
- var ApiError = class extends BaseError.extend("API", "API error") {
62
+ var ApiError = class extends BaseError.extend("ApiError", "API error") {
63
+ };
64
+ var SystemError = class extends BaseError.extend("SystemError", "System error") {
66
65
  };
67
- var SystemError = class extends BaseError.extend("SYSTEM", "System error") {
66
+ var InternalError = class extends BaseError.extend("InternalError", "Internal error") {
68
67
  };
69
- var InternalError = class extends BaseError.extend("INTERNAL", "Internal error") {
68
+ var TimeoutError = class extends BaseError.extend("TimeoutError", "Timeout") {
70
69
  };
71
- var TimeoutError = class extends BaseError.extend("TIMEOUT", "Timeout") {
70
+ var AbortedError = class extends BaseError.extend("AbortedError", "Aborted") {
72
71
  };
73
- var AbortedError = class extends BaseError.extend("ABORTED", "Aborted") {
72
+ var NotImplementedError = class extends BaseError.extend("NotImplementedError", "Not implemented") {
74
73
  };
75
- var NotImplementedError = class extends BaseError.extend("NOT_IMPLEMENTED", "Not implemented") {
74
+ var RuntimeServiceError = class extends BaseError.extend("RuntimeServiceError", "Runtime service error") {
76
75
  };
77
76
  export {
78
77
  AbortedError,
@@ -80,6 +79,7 @@ export {
80
79
  BaseError,
81
80
  InternalError,
82
81
  NotImplementedError,
82
+ RuntimeServiceError,
83
83
  SystemError,
84
84
  TimeoutError
85
85
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/base.ts", "../../../src/errors.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Options for creating a BaseError.\n */\nexport type BaseErrorOptions = ErrorOptions & {\n /**\n * Override base message.\n */\n message?: string;\n\n /**\n * Structured details about the error.\n */\n context?: Record<string, unknown>;\n};\n\n/**\n * Base class for all DXOS errors.\n */\nexport class BaseError<Code extends string = string> extends Error {\n /**\n * Primary way of defining new error classes.\n * Extended class may specialize constructor for required context params.\n * @param code - Error code.\n * @param message - Default error message.\n */\n static extend<Code extends string = string>(code: Code, message?: string) {\n return class ExtendedError extends BaseError<Code> {\n static code = code;\n\n static is(error: unknown): error is BaseError {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code;\n }\n\n static wrap(\n options?: Omit<BaseErrorOptions, 'cause'> & { ifTypeDiffers?: boolean },\n ): (error: unknown) => ExtendedError {\n const wrapFn = (error: unknown) => {\n if (options?.ifTypeDiffers === true && this.is(error)) {\n return error as ExtendedError;\n }\n const newError: ExtendedError = new this({ message, ...options, cause: error });\n Error.captureStackTrace(newError, wrapFn); // Position stack-trace to start from the caller of `wrap`.\n return newError;\n };\n return wrapFn;\n }\n\n constructor(options?: BaseErrorOptions) {\n super(code, { message: options?.message ?? message, ...options });\n }\n };\n }\n\n // NOTE: Errors go through odd transformations and the private fields seem to break.\n code: Code;\n context: Record<string, unknown>;\n\n constructor(code: Code, options?: BaseErrorOptions) {\n super(options?.message, { cause: options?.cause });\n\n this.code = code;\n this.context = options?.context ?? {};\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n override get name() {\n return this.code;\n }\n\n /** Fallback message. */\n override get message() {\n return this.constructor.name;\n }\n\n // For effect error matching.\n get _tag(): Code {\n return this.code;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError } from './base';\n\nexport class ApiError extends BaseError.extend('API', 'API error') {}\n\nexport class SystemError extends BaseError.extend('SYSTEM', 'System error') {}\n\nexport class InternalError extends BaseError.extend('INTERNAL', 'Internal error') {}\n\nexport class TimeoutError extends BaseError.extend('TIMEOUT', 'Timeout') {}\n\nexport class AbortedError extends BaseError.extend('ABORTED', 'Aborted') {}\n\nexport class NotImplementedError extends BaseError.extend('NOT_IMPLEMENTED', 'Not implemented') {}\n"],
5
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E,IAAMG,eAAN,cAA2BJ,UAAUC,OAAO,WAAW,SAAA,EAAA;AAAY;AAEnE,IAAMI,eAAN,cAA2BL,UAAUC,OAAO,WAAW,SAAA,EAAA;AAAY;AAEnE,IAAMK,sBAAN,cAAkCN,UAAUC,OAAO,mBAAmB,iBAAA,EAAA;AAAoB;",
6
- "names": ["BaseError", "Error", "extend", "code", "message", "ExtendedError", "is", "error", "wrap", "options", "wrapFn", "ifTypeDiffers", "newError", "cause", "captureStackTrace", "context", "Object", "setPrototypeOf", "prototype", "name", "_tag", "ApiError", "BaseError", "extend", "SystemError", "InternalError", "TimeoutError", "AbortedError", "NotImplementedError"]
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Options for creating a BaseError.\n */\nexport type BaseErrorOptions = ErrorOptions & {\n /**\n * Override base message.\n */\n message?: string;\n\n /**\n * Structured details about the error.\n */\n context?: Record<string, unknown>;\n};\n\n/**\n * Base class for all DXOS errors.\n */\nexport class BaseError<Name extends string = string> extends Error {\n /**\n * Primary way of defining new error classes.\n * Extended class may specialize constructor for required context params.\n * @param name - Error name.\n * @param message - Default error message.\n */\n static extend<Name extends string = string>(name: Name, message?: string) {\n return class ExtendedError extends BaseError<Name> {\n static override name: Name = name;\n\n static is(error: unknown): error is BaseError {\n return typeof error === 'object' && error !== null && 'name' in error && error.name === name;\n }\n\n static wrap(\n options?: Omit<BaseErrorOptions, 'cause'> & { ifTypeDiffers?: boolean },\n ): (error: unknown) => ExtendedError {\n const wrapFn = (error: unknown) => {\n if (options?.ifTypeDiffers === true && this.is(error)) {\n return error as ExtendedError;\n }\n const newError: ExtendedError = new this({ message, ...options, cause: error });\n Error.captureStackTrace(newError, wrapFn); // Position stack-trace to start from the caller of `wrap`.\n return newError;\n };\n return wrapFn;\n }\n\n constructor(options?: BaseErrorOptions) {\n super(name, { message: options?.message ?? message, ...options });\n }\n };\n }\n\n // NOTE: Errors go through odd transformations and the private fields seem to break.\n override name: Name;\n context: Record<string, unknown>;\n\n constructor(name: Name, options?: BaseErrorOptions) {\n super(options?.message, { cause: options?.cause });\n\n this.name = name;\n this.context = options?.context ?? {};\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** Fallback message. */\n override get message() {\n return this.constructor.name;\n }\n\n // For effect error matching.\n get _tag(): Name {\n return this.name;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError } from './base';\n\nexport class ApiError extends BaseError.extend('ApiError', 'API error') {}\n\nexport class SystemError extends BaseError.extend('SystemError', 'System error') {}\n\nexport class InternalError extends BaseError.extend('InternalError', 'Internal error') {}\n\nexport class TimeoutError extends BaseError.extend('TimeoutError', 'Timeout') {}\n\nexport class AbortedError extends BaseError.extend('AbortedError', 'Aborted') {}\n\nexport class NotImplementedError extends BaseError.extend('NotImplementedError', 'Not implemented') {}\n\nexport class RuntimeServiceError extends BaseError.extend('RuntimeServiceError', 'Runtime service error') {}\n"],
5
+ "mappings": ";;;AAsBO,IAAMA,YAAN,MAAMA,mBAAgDC,MAAAA;;;;;;;EAO3D,OAAOC,OAAqCC,MAAYC,SAAkB;AACxE,WAAO,MAAMC,sBAAsBL,WAAAA;MACjC,OAAgBG,OAAaA;MAE7B,OAAOG,GAAGC,OAAoC;AAC5C,eAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,UAAUA,SAASA,MAAMJ,SAASA;MAC1F;MAEA,OAAOK,KACLC,SACmC;AACnC,cAAMC,SAAS,CAACH,UAAAA;AACd,cAAIE,SAASE,kBAAkB,QAAQ,KAAKL,GAAGC,KAAAA,GAAQ;AACrD,mBAAOA;UACT;AACA,gBAAMK,WAA0B,IAAI,KAAK;YAAER;YAAS,GAAGK;YAASI,OAAON;UAAM,CAAA;AAC7EN,gBAAMa,kBAAkBF,UAAUF,MAAAA;AAClC,iBAAOE;QACT;AACA,eAAOF;MACT;MAEA,YAAYD,SAA4B;AACtC,cAAMN,MAAM;UAAEC,SAASK,SAASL,WAAWA;UAAS,GAAGK;QAAQ,CAAA;MACjE;IACF;EACF;;EAGSN;EACTY;EAEA,YAAYZ,MAAYM,SAA4B;AAClD,UAAMA,SAASL,SAAS;MAAES,OAAOJ,SAASI;IAAM,CAAA;AAEhD,SAAKV,OAAOA;AACZ,SAAKY,UAAUN,SAASM,WAAW,CAAC;AACpCC,WAAOC,eAAe,MAAM,WAAWC,SAAS;EAClD;;EAGA,IAAad,UAAU;AACrB,WAAO,KAAK,YAAYD;EAC1B;;EAGA,IAAIgB,OAAa;AACf,WAAO,KAAKhB;EACd;AACF;;;ACxEO,IAAMiB,WAAN,cAAuBC,UAAUC,OAAO,YAAY,WAAA,EAAA;AAAc;AAElE,IAAMC,cAAN,cAA0BF,UAAUC,OAAO,eAAe,cAAA,EAAA;AAAiB;AAE3E,IAAME,gBAAN,cAA4BH,UAAUC,OAAO,iBAAiB,gBAAA,EAAA;AAAmB;AAEjF,IAAMG,eAAN,cAA2BJ,UAAUC,OAAO,gBAAgB,SAAA,EAAA;AAAY;AAExE,IAAMI,eAAN,cAA2BL,UAAUC,OAAO,gBAAgB,SAAA,EAAA;AAAY;AAExE,IAAMK,sBAAN,cAAkCN,UAAUC,OAAO,uBAAuB,iBAAA,EAAA;AAAoB;AAE9F,IAAMM,sBAAN,cAAkCP,UAAUC,OAAO,uBAAuB,uBAAA,EAAA;AAA0B;",
6
+ "names": ["BaseError", "Error", "extend", "name", "message", "ExtendedError", "is", "error", "wrap", "options", "wrapFn", "ifTypeDiffers", "newError", "cause", "captureStackTrace", "context", "Object", "setPrototypeOf", "prototype", "_tag", "ApiError", "BaseError", "extend", "SystemError", "InternalError", "TimeoutError", "AbortedError", "NotImplementedError", "RuntimeServiceError"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/base.ts":{"bytes":7183,"imports":[],"format":"esm"},"src/errors.ts":{"bytes":2213,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"}],"format":"esm"},"src/index.ts":{"bytes":523,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4647},"dist/lib/node-esm/index.mjs":{"imports":[],"exports":["AbortedError","ApiError","BaseError","InternalError","NotImplementedError","SystemError","TimeoutError"],"entryPoint":"src/index.ts","inputs":{"src/base.ts":{"bytesInOutput":1594},"src/index.ts":{"bytesInOutput":0},"src/errors.ts":{"bytesInOutput":491}},"bytes":2369}}}
1
+ {"inputs":{"src/base.ts":{"bytes":7022,"imports":[],"format":"esm"},"src/errors.ts":{"bytes":2648,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"}],"format":"esm"},"src/index.ts":{"bytes":523,"imports":[{"path":"src/base.ts","kind":"import-statement","original":"./base"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4802},"dist/lib/node-esm/index.mjs":{"imports":[],"exports":["AbortedError","ApiError","BaseError","InternalError","NotImplementedError","RuntimeServiceError","SystemError","TimeoutError"],"entryPoint":"src/index.ts","inputs":{"src/base.ts":{"bytesInOutput":1553},"src/index.ts":{"bytesInOutput":0},"src/errors.ts":{"bytesInOutput":630}},"bytes":2490}}}
@@ -14,50 +14,47 @@ export type BaseErrorOptions = ErrorOptions & {
14
14
  /**
15
15
  * Base class for all DXOS errors.
16
16
  */
17
- export declare class BaseError<Code extends string = string> extends Error {
17
+ export declare class BaseError<Name extends string = string> extends Error {
18
18
  /**
19
19
  * Primary way of defining new error classes.
20
20
  * Extended class may specialize constructor for required context params.
21
- * @param code - Error code.
21
+ * @param name - Error name.
22
22
  * @param message - Default error message.
23
23
  */
24
- static extend<Code extends string = string>(code: Code, message?: string): {
24
+ static extend<Name extends string = string>(name: Name, message?: string): {
25
25
  new (options?: BaseErrorOptions): {
26
- code: Code;
26
+ name: Name;
27
27
  context: Record<string, unknown>;
28
- get name(): Code;
29
28
  /** Fallback message. */
30
29
  get message(): string;
31
- get _tag(): Code;
30
+ get _tag(): Name;
32
31
  stack?: string;
33
32
  cause?: unknown;
34
33
  };
35
- code: Code;
34
+ name: Name;
36
35
  is(error: unknown): error is BaseError;
37
36
  wrap(options?: Omit<BaseErrorOptions, "cause"> & {
38
37
  ifTypeDiffers?: boolean;
39
38
  }): (error: unknown) => {
40
- code: Code;
39
+ name: Name;
41
40
  context: Record<string, unknown>;
42
- get name(): Code;
43
41
  /** Fallback message. */
44
42
  get message(): string;
45
- get _tag(): Code;
43
+ get _tag(): Name;
46
44
  stack?: string;
47
45
  cause?: unknown;
48
46
  };
49
- extend<Code extends string = string>(code: Code, message?: string): /*elided*/ any;
47
+ extend<Name extends string = string>(name: Name, message?: string): /*elided*/ any;
50
48
  isError(error: unknown): error is Error;
51
49
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
52
50
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
53
51
  stackTraceLimit: number;
54
52
  };
55
- code: Code;
53
+ name: Name;
56
54
  context: Record<string, unknown>;
57
- constructor(code: Code, options?: BaseErrorOptions);
58
- get name(): Code;
55
+ constructor(name: Name, options?: BaseErrorOptions);
59
56
  /** Fallback message. */
60
57
  get message(): string;
61
- get _tag(): Code;
58
+ get _tag(): Name;
62
59
  }
63
60
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/base.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC5C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,C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