@dxos/errors 0.8.4-main.67995b8 → 0.8.4-main.69d29f4
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/lib/browser/index.mjs +50 -42
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +50 -42
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/base.d.ts +34 -36
- package/dist/types/src/base.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +247 -228
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -4
- package/src/base.ts +40 -37
- package/src/errors.test.ts +25 -5
- package/src/errors.ts +8 -6
|
@@ -2,75 +2,83 @@
|
|
|
2
2
|
var BaseError = class _BaseError extends Error {
|
|
3
3
|
/**
|
|
4
4
|
* Primary way of defining new error classes.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* export class AiInputPreprocessingError extends BaseError.extend('AI_INPUT_PREPROCESSING_ERROR') {}
|
|
10
|
-
* ```
|
|
5
|
+
* Extended class may specialize constructor for required context params.
|
|
6
|
+
* @param name - Error name.
|
|
7
|
+
* @param message - Default error message.
|
|
11
8
|
*/
|
|
12
|
-
static extend(
|
|
13
|
-
return class extends _BaseError {
|
|
14
|
-
static
|
|
15
|
-
this.code = code;
|
|
16
|
-
}
|
|
9
|
+
static extend(name, message) {
|
|
10
|
+
return class ExtendedError extends _BaseError {
|
|
11
|
+
static name = name;
|
|
17
12
|
static is(error) {
|
|
18
|
-
return typeof error === "object" && error !== null && "
|
|
13
|
+
return typeof error === "object" && error !== null && "name" in error && error.name === name;
|
|
19
14
|
}
|
|
20
|
-
static wrap(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
static wrap(options) {
|
|
16
|
+
const wrapFn = (error) => {
|
|
17
|
+
if (options?.ifTypeDiffers === true && this.is(error)) {
|
|
18
|
+
return error;
|
|
19
|
+
}
|
|
20
|
+
const newError = new this({
|
|
21
|
+
message,
|
|
22
|
+
...options,
|
|
23
|
+
cause: error
|
|
24
|
+
});
|
|
25
|
+
Error.captureStackTrace(newError, wrapFn);
|
|
26
|
+
return newError;
|
|
27
|
+
};
|
|
28
|
+
return wrapFn;
|
|
25
29
|
}
|
|
26
|
-
constructor(
|
|
27
|
-
super(
|
|
30
|
+
constructor(options) {
|
|
31
|
+
super(name, {
|
|
32
|
+
message: options?.message ?? message,
|
|
33
|
+
...options
|
|
34
|
+
});
|
|
28
35
|
}
|
|
29
36
|
};
|
|
30
37
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
// NOTE: Errors go through odd transformations and the private fields seem to break.
|
|
39
|
+
name;
|
|
40
|
+
context;
|
|
41
|
+
constructor(name, options) {
|
|
42
|
+
super(options?.message, {
|
|
43
|
+
cause: options?.cause
|
|
44
|
+
});
|
|
45
|
+
this.name = name;
|
|
46
|
+
this.context = options?.context ?? {};
|
|
37
47
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
38
48
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
get code() {
|
|
43
|
-
return this.#code;
|
|
49
|
+
/** Fallback message. */
|
|
50
|
+
get message() {
|
|
51
|
+
return this.constructor.name;
|
|
44
52
|
}
|
|
45
53
|
// For effect error matching.
|
|
46
54
|
get _tag() {
|
|
47
|
-
return this
|
|
48
|
-
}
|
|
49
|
-
get context() {
|
|
50
|
-
return this.#context;
|
|
55
|
+
return this.name;
|
|
51
56
|
}
|
|
52
57
|
};
|
|
53
58
|
|
|
54
59
|
// src/errors.ts
|
|
55
|
-
var
|
|
60
|
+
var ApiError = class extends BaseError.extend("ApiError", "API error") {
|
|
61
|
+
};
|
|
62
|
+
var SystemError = class extends BaseError.extend("SystemError", "System error") {
|
|
56
63
|
};
|
|
57
|
-
var
|
|
64
|
+
var InternalError = class extends BaseError.extend("InternalError", "Internal error") {
|
|
58
65
|
};
|
|
59
|
-
var
|
|
66
|
+
var TimeoutError = class extends BaseError.extend("TimeoutError", "Timeout") {
|
|
60
67
|
};
|
|
61
|
-
var
|
|
68
|
+
var AbortedError = class extends BaseError.extend("AbortedError", "Aborted") {
|
|
62
69
|
};
|
|
63
|
-
var
|
|
70
|
+
var NotImplementedError = class extends BaseError.extend("NotImplementedError", "Not implemented") {
|
|
64
71
|
};
|
|
65
|
-
var
|
|
72
|
+
var RuntimeServiceError = class extends BaseError.extend("RuntimeServiceError", "Runtime service error") {
|
|
66
73
|
};
|
|
67
74
|
export {
|
|
68
75
|
AbortedError,
|
|
69
76
|
ApiError,
|
|
70
77
|
BaseError,
|
|
71
78
|
InternalError,
|
|
79
|
+
NotImplementedError,
|
|
80
|
+
RuntimeServiceError,
|
|
72
81
|
SystemError,
|
|
73
|
-
TimeoutError
|
|
74
|
-
UnimplementedError
|
|
82
|
+
TimeoutError
|
|
75
83
|
};
|
|
76
84
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -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\nexport type BaseErrorOptions = {\n /**\n *
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": ["BaseError", "Error", "extend", "
|
|
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":
|
|
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}}}
|
|
@@ -4,75 +4,83 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
4
4
|
var BaseError = class _BaseError extends Error {
|
|
5
5
|
/**
|
|
6
6
|
* Primary way of defining new error classes.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* export class AiInputPreprocessingError extends BaseError.extend('AI_INPUT_PREPROCESSING_ERROR') {}
|
|
12
|
-
* ```
|
|
7
|
+
* Extended class may specialize constructor for required context params.
|
|
8
|
+
* @param name - Error name.
|
|
9
|
+
* @param message - Default error message.
|
|
13
10
|
*/
|
|
14
|
-
static extend(
|
|
15
|
-
return class extends _BaseError {
|
|
16
|
-
static
|
|
17
|
-
this.code = code;
|
|
18
|
-
}
|
|
11
|
+
static extend(name, message) {
|
|
12
|
+
return class ExtendedError extends _BaseError {
|
|
13
|
+
static name = name;
|
|
19
14
|
static is(error) {
|
|
20
|
-
return typeof error === "object" && error !== null && "
|
|
15
|
+
return typeof error === "object" && error !== null && "name" in error && error.name === name;
|
|
21
16
|
}
|
|
22
|
-
static wrap(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
static wrap(options) {
|
|
18
|
+
const wrapFn = (error) => {
|
|
19
|
+
if (options?.ifTypeDiffers === true && this.is(error)) {
|
|
20
|
+
return error;
|
|
21
|
+
}
|
|
22
|
+
const newError = new this({
|
|
23
|
+
message,
|
|
24
|
+
...options,
|
|
25
|
+
cause: error
|
|
26
|
+
});
|
|
27
|
+
Error.captureStackTrace(newError, wrapFn);
|
|
28
|
+
return newError;
|
|
29
|
+
};
|
|
30
|
+
return wrapFn;
|
|
27
31
|
}
|
|
28
|
-
constructor(
|
|
29
|
-
super(
|
|
32
|
+
constructor(options) {
|
|
33
|
+
super(name, {
|
|
34
|
+
message: options?.message ?? message,
|
|
35
|
+
...options
|
|
36
|
+
});
|
|
30
37
|
}
|
|
31
38
|
};
|
|
32
39
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
// NOTE: Errors go through odd transformations and the private fields seem to break.
|
|
41
|
+
name;
|
|
42
|
+
context;
|
|
43
|
+
constructor(name, options) {
|
|
44
|
+
super(options?.message, {
|
|
45
|
+
cause: options?.cause
|
|
46
|
+
});
|
|
47
|
+
this.name = name;
|
|
48
|
+
this.context = options?.context ?? {};
|
|
39
49
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
40
50
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
get code() {
|
|
45
|
-
return this.#code;
|
|
51
|
+
/** Fallback message. */
|
|
52
|
+
get message() {
|
|
53
|
+
return this.constructor.name;
|
|
46
54
|
}
|
|
47
55
|
// For effect error matching.
|
|
48
56
|
get _tag() {
|
|
49
|
-
return this
|
|
50
|
-
}
|
|
51
|
-
get context() {
|
|
52
|
-
return this.#context;
|
|
57
|
+
return this.name;
|
|
53
58
|
}
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
// src/errors.ts
|
|
57
|
-
var
|
|
62
|
+
var ApiError = class extends BaseError.extend("ApiError", "API error") {
|
|
63
|
+
};
|
|
64
|
+
var SystemError = class extends BaseError.extend("SystemError", "System error") {
|
|
58
65
|
};
|
|
59
|
-
var
|
|
66
|
+
var InternalError = class extends BaseError.extend("InternalError", "Internal error") {
|
|
60
67
|
};
|
|
61
|
-
var
|
|
68
|
+
var TimeoutError = class extends BaseError.extend("TimeoutError", "Timeout") {
|
|
62
69
|
};
|
|
63
|
-
var
|
|
70
|
+
var AbortedError = class extends BaseError.extend("AbortedError", "Aborted") {
|
|
64
71
|
};
|
|
65
|
-
var
|
|
72
|
+
var NotImplementedError = class extends BaseError.extend("NotImplementedError", "Not implemented") {
|
|
66
73
|
};
|
|
67
|
-
var
|
|
74
|
+
var RuntimeServiceError = class extends BaseError.extend("RuntimeServiceError", "Runtime service error") {
|
|
68
75
|
};
|
|
69
76
|
export {
|
|
70
77
|
AbortedError,
|
|
71
78
|
ApiError,
|
|
72
79
|
BaseError,
|
|
73
80
|
InternalError,
|
|
81
|
+
NotImplementedError,
|
|
82
|
+
RuntimeServiceError,
|
|
74
83
|
SystemError,
|
|
75
|
-
TimeoutError
|
|
76
|
-
UnimplementedError
|
|
84
|
+
TimeoutError
|
|
77
85
|
};
|
|
78
86
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -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\nexport type BaseErrorOptions = {\n /**\n *
|
|
5
|
-
"mappings": ";;;
|
|
6
|
-
"names": ["BaseError", "Error", "extend", "
|
|
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":
|
|
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}}}
|
package/dist/types/src/base.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Options for creating a BaseError.
|
|
3
|
+
*/
|
|
4
|
+
export type BaseErrorOptions = ErrorOptions & {
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
* An instance of Error.
|
|
6
|
+
* Override base message.
|
|
5
7
|
*/
|
|
6
|
-
|
|
8
|
+
message?: string;
|
|
7
9
|
/**
|
|
8
10
|
* Structured details about the error.
|
|
9
11
|
*/
|
|
@@ -12,51 +14,47 @@ export type BaseErrorOptions = {
|
|
|
12
14
|
/**
|
|
13
15
|
* Base class for all DXOS errors.
|
|
14
16
|
*/
|
|
15
|
-
export declare class BaseError<
|
|
16
|
-
#private;
|
|
17
|
+
export declare class BaseError<Name extends string = string> extends Error {
|
|
17
18
|
/**
|
|
18
19
|
* Primary way of defining new error classes.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* ```ts
|
|
23
|
-
* export class AiInputPreprocessingError extends BaseError.extend('AI_INPUT_PREPROCESSING_ERROR') {}
|
|
24
|
-
* ```
|
|
20
|
+
* Extended class may specialize constructor for required context params.
|
|
21
|
+
* @param name - Error name.
|
|
22
|
+
* @param message - Default error message.
|
|
25
23
|
*/
|
|
26
|
-
static extend<
|
|
27
|
-
new (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
readonly context: Record<string, unknown>;
|
|
34
|
-
message: string;
|
|
24
|
+
static extend<Name extends string = string>(name: Name, message?: string): {
|
|
25
|
+
new (options?: BaseErrorOptions): {
|
|
26
|
+
name: Name;
|
|
27
|
+
context: Record<string, unknown>;
|
|
28
|
+
/** Fallback message. */
|
|
29
|
+
get message(): string;
|
|
30
|
+
get _tag(): Name;
|
|
35
31
|
stack?: string;
|
|
36
32
|
cause?: unknown;
|
|
37
33
|
};
|
|
38
|
-
|
|
34
|
+
name: Name;
|
|
39
35
|
is(error: unknown): error is BaseError;
|
|
40
|
-
wrap(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
wrap(options?: Omit<BaseErrorOptions, "cause"> & {
|
|
37
|
+
ifTypeDiffers?: boolean;
|
|
38
|
+
}): (error: unknown) => {
|
|
39
|
+
name: Name;
|
|
40
|
+
context: Record<string, unknown>;
|
|
41
|
+
/** Fallback message. */
|
|
42
|
+
get message(): string;
|
|
43
|
+
get _tag(): Name;
|
|
48
44
|
stack?: string;
|
|
49
45
|
cause?: unknown;
|
|
50
46
|
};
|
|
51
|
-
extend<
|
|
47
|
+
extend<Name extends string = string>(name: Name, message?: string): /*elided*/ any;
|
|
48
|
+
isError(error: unknown): error is Error;
|
|
52
49
|
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
53
50
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
54
51
|
stackTraceLimit: number;
|
|
55
52
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
get
|
|
53
|
+
name: Name;
|
|
54
|
+
context: Record<string, unknown>;
|
|
55
|
+
constructor(name: Name, options?: BaseErrorOptions);
|
|
56
|
+
/** Fallback message. */
|
|
57
|
+
get message(): string;
|
|
58
|
+
get _tag(): Name;
|
|
61
59
|
}
|
|
62
60
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/base.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG;
|
|
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,CAAE,SAAQ,KAAK;IAChE;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM;uBAsB9C,gBAAgB;;qBAQjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;YAUhC,wBAAwB;;;;;;cAtCE,IAAI;kBAET,OAAO,GAAG,KAAK,IAAI,SAAS;uBAKjC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;YAAE,aAAa,CAAC,EAAE,OAAO,CAAA;SAAE,GACtE,CAAC,KAAK,EAAE,OAAO;;qBAoBb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;YAUhC,wBAAwB;;;;;SA9BgB;eAV1B,IAAI,SAAS,MAAM,iBAAiB,IAAI,YAAY,MAAM;;;;;;IA6B/D,IAAI,EAAE,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAErB,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAQlD,wBAAwB;IACxB,IAAa,OAAO,WAEnB;IAGD,IAAI,IAAI,IAAI,IAAI,CAEf;CACF"}
|