@alessiofrittoli/exception 3.5.0 → 4.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.
- package/README.md +190 -249
- package/dist/abort/index.cjs +1 -0
- package/dist/abort/index.d.cts +29 -0
- package/dist/abort/index.d.mts +29 -0
- package/dist/abort/index.mjs +1 -0
- package/dist/code/index.cjs +1 -0
- package/dist/code/index.d.cts +19 -0
- package/dist/code/index.d.mts +19 -0
- package/dist/code/index.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +177 -0
- package/dist/index.d.mts +164 -58
- package/dist/index.mjs +1 -1
- package/license.md +1 -1
- package/package.json +34 -45
- package/dist/abort.d.mts +0 -35
- package/dist/abort.d.ts +0 -35
- package/dist/abort.js +0 -1
- package/dist/abort.mjs +0 -1
- package/dist/chunk-OBRRZX4D.js +0 -1
- package/dist/chunk-PSRQLNM6.js +0 -1
- package/dist/chunk-RAHIXT6K.mjs +0 -1
- package/dist/chunk-VBWDYSF3.mjs +0 -1
- package/dist/code.d.mts +0 -19
- package/dist/code.d.ts +0 -19
- package/dist/code.js +0 -1
- package/dist/code.mjs +0 -1
- package/dist/index.d.ts +0 -71
- package/dist/index.js +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { ErrorCode } from "./code/index.cjs";
|
|
2
|
+
//#region src/error-names.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Exception Name.
|
|
5
|
+
*
|
|
6
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names)
|
|
7
|
+
*/
|
|
8
|
+
export declare const ExceptionName: {
|
|
9
|
+
readonly Exception: "Exception";
|
|
10
|
+
readonly AbortError: "AbortError";
|
|
11
|
+
readonly NotAllowedError: "NotAllowedError";
|
|
12
|
+
readonly NotFoundError: "NotFoundError";
|
|
13
|
+
readonly NotSupportedError: "NotSupportedError";
|
|
14
|
+
readonly InvalidStateError: "InvalidStateError";
|
|
15
|
+
readonly InvalidAccessError: "InvalidAccessError";
|
|
16
|
+
readonly NetworkError: "NetworkError";
|
|
17
|
+
readonly SecurityError: "SecurityError";
|
|
18
|
+
readonly TimeoutError: "TimeoutError";
|
|
19
|
+
readonly QuotaExceededError: "QuotaExceededError";
|
|
20
|
+
readonly DataError: "DataError";
|
|
21
|
+
readonly EncodingError: "EncodingError";
|
|
22
|
+
readonly OperationError: "OperationError";
|
|
23
|
+
readonly ConstraintError: "ConstraintError";
|
|
24
|
+
readonly TransactionInactiveError: "TransactionInactiveError";
|
|
25
|
+
readonly ReadOnlyError: "ReadOnlyError";
|
|
26
|
+
readonly VersionError: "VersionError";
|
|
27
|
+
readonly NoModificationAllowedError: "NoModificationAllowedError";
|
|
28
|
+
readonly HierarchyRequestError: "HierarchyRequestError";
|
|
29
|
+
readonly WrongDocumentError: "WrongDocumentError";
|
|
30
|
+
readonly InvalidCharacterError: "InvalidCharacterError";
|
|
31
|
+
readonly NamespaceError: "NamespaceError";
|
|
32
|
+
readonly SyntaxError: "SyntaxError";
|
|
33
|
+
readonly DataCloneError: "DataCloneError";
|
|
34
|
+
readonly URLMismatchError: "URLMismatchError";
|
|
35
|
+
readonly InvalidModificationError: "InvalidModificationError";
|
|
36
|
+
readonly NotReadableError: "NotReadableError";
|
|
37
|
+
};
|
|
38
|
+
export type ExceptionName = (typeof ExceptionName)[keyof typeof ExceptionName];
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/index.d.ts
|
|
41
|
+
/**
|
|
42
|
+
* Interface representing the options for an Exception.
|
|
43
|
+
*
|
|
44
|
+
* @template T The type of the error code.
|
|
45
|
+
*
|
|
46
|
+
* @extends ErrorOptions
|
|
47
|
+
*/
|
|
48
|
+
export interface ExceptionOptions<T = ErrorCode> extends ErrorOptions {
|
|
49
|
+
/**
|
|
50
|
+
* The error interface name.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link ExceptionName} for a list of possible standard values.
|
|
53
|
+
*
|
|
54
|
+
* @default ExceptionName.Exception
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The error message containing technical informations about the error.
|
|
59
|
+
*
|
|
60
|
+
* It shouldn't be rendered to the user.
|
|
61
|
+
*/
|
|
62
|
+
message?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The error title.
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
title?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The error description.
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
description?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The error code associated with the Exception.
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
code: T;
|
|
78
|
+
/**
|
|
79
|
+
* Indicates whether the error is a critical error.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
isCritical?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The HTTP status code associated with the Exception.
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
status?: number;
|
|
89
|
+
/**
|
|
90
|
+
* The error cause.
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
cause?: unknown;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Exception Class.
|
|
97
|
+
*
|
|
98
|
+
* @template T The type of the code property of the Exception. Defaults to `ErrorCode`.
|
|
99
|
+
*
|
|
100
|
+
* @extends Error
|
|
101
|
+
* @implements ExceptionOptions<T>
|
|
102
|
+
*/
|
|
103
|
+
export declare class Exception<T = ErrorCode> extends Error {
|
|
104
|
+
private readonly __typename;
|
|
105
|
+
/**
|
|
106
|
+
* The error interface name.
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
readonly name: string;
|
|
110
|
+
/**
|
|
111
|
+
* The error message containing technical informations about the error.
|
|
112
|
+
*
|
|
113
|
+
* ⚠️ do not render `Exception.message` to the user.
|
|
114
|
+
*/
|
|
115
|
+
readonly message: string;
|
|
116
|
+
/**
|
|
117
|
+
* The error title that can be rendered to the user.
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
readonly title: string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* The error description that can be rendered to the user.
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
readonly description: string | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* The error code.
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
readonly code: T;
|
|
131
|
+
/**
|
|
132
|
+
* Indicates whether the error is a critical error.
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
readonly isCritical: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* The HTTP status code associated with the Exception.
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
readonly status: number | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* The error cause.
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
readonly cause: unknown;
|
|
146
|
+
/**
|
|
147
|
+
* Constructs a new Exception instance.
|
|
148
|
+
*
|
|
149
|
+
* @param options An object defining Exception options. See {@link ExceptionOptions} for more info.
|
|
150
|
+
*/
|
|
151
|
+
constructor(options: ExceptionOptions<T>);
|
|
152
|
+
/**
|
|
153
|
+
* Determines if the provided error is an instance of the Exception class.
|
|
154
|
+
*
|
|
155
|
+
* @template T The type of the code property of the Exception.
|
|
156
|
+
*
|
|
157
|
+
* @param error The error to check.
|
|
158
|
+
* @returns `true` if the error is an instance of Exception or has a `__typename` property equal to 'Exception', `false` otherwise.
|
|
159
|
+
*/
|
|
160
|
+
static isException<T = ErrorCode>(error: any): error is Exception<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Determines if the provided error is an instance of the Exception class and has the ABORT ErrorCode.
|
|
163
|
+
*
|
|
164
|
+
* @template T The type of the code property of the Exception.
|
|
165
|
+
*
|
|
166
|
+
* @param error The error to check.
|
|
167
|
+
* @returns `true` if the error is an `Exception` and has the ABORT ErrorCode, `false` otherwise.
|
|
168
|
+
*/
|
|
169
|
+
static isAbortError<T = ErrorCode>(error: any, code?: T): error is Exception<T>;
|
|
170
|
+
/**
|
|
171
|
+
* Converts the instance to a JSON object.
|
|
172
|
+
*
|
|
173
|
+
* @returns A JSON representation of the instance, including the message property.
|
|
174
|
+
*/
|
|
175
|
+
toJSON(): this;
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -1,71 +1,177 @@
|
|
|
1
|
-
import { ErrorCode } from
|
|
2
|
-
|
|
1
|
+
import { ErrorCode } from "./code/index.mjs";
|
|
2
|
+
//#region src/error-names.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Exception Name.
|
|
5
|
+
*
|
|
6
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names)
|
|
7
|
+
*/
|
|
8
|
+
export declare const ExceptionName: {
|
|
9
|
+
readonly Exception: "Exception";
|
|
10
|
+
readonly AbortError: "AbortError";
|
|
11
|
+
readonly NotAllowedError: "NotAllowedError";
|
|
12
|
+
readonly NotFoundError: "NotFoundError";
|
|
13
|
+
readonly NotSupportedError: "NotSupportedError";
|
|
14
|
+
readonly InvalidStateError: "InvalidStateError";
|
|
15
|
+
readonly InvalidAccessError: "InvalidAccessError";
|
|
16
|
+
readonly NetworkError: "NetworkError";
|
|
17
|
+
readonly SecurityError: "SecurityError";
|
|
18
|
+
readonly TimeoutError: "TimeoutError";
|
|
19
|
+
readonly QuotaExceededError: "QuotaExceededError";
|
|
20
|
+
readonly DataError: "DataError";
|
|
21
|
+
readonly EncodingError: "EncodingError";
|
|
22
|
+
readonly OperationError: "OperationError";
|
|
23
|
+
readonly ConstraintError: "ConstraintError";
|
|
24
|
+
readonly TransactionInactiveError: "TransactionInactiveError";
|
|
25
|
+
readonly ReadOnlyError: "ReadOnlyError";
|
|
26
|
+
readonly VersionError: "VersionError";
|
|
27
|
+
readonly NoModificationAllowedError: "NoModificationAllowedError";
|
|
28
|
+
readonly HierarchyRequestError: "HierarchyRequestError";
|
|
29
|
+
readonly WrongDocumentError: "WrongDocumentError";
|
|
30
|
+
readonly InvalidCharacterError: "InvalidCharacterError";
|
|
31
|
+
readonly NamespaceError: "NamespaceError";
|
|
32
|
+
readonly SyntaxError: "SyntaxError";
|
|
33
|
+
readonly DataCloneError: "DataCloneError";
|
|
34
|
+
readonly URLMismatchError: "URLMismatchError";
|
|
35
|
+
readonly InvalidModificationError: "InvalidModificationError";
|
|
36
|
+
readonly NotReadableError: "NotReadableError";
|
|
37
|
+
};
|
|
38
|
+
export type ExceptionName = (typeof ExceptionName)[keyof typeof ExceptionName];
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/index.d.ts
|
|
3
41
|
/**
|
|
4
42
|
* Interface representing the options for an Exception.
|
|
5
43
|
*
|
|
6
|
-
* @template
|
|
44
|
+
* @template T The type of the error code.
|
|
45
|
+
*
|
|
7
46
|
* @extends ErrorOptions
|
|
8
47
|
*/
|
|
9
|
-
interface ExceptionOptions<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
48
|
+
export interface ExceptionOptions<T = ErrorCode> extends ErrorOptions {
|
|
49
|
+
/**
|
|
50
|
+
* The error interface name.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link ExceptionName} for a list of possible standard values.
|
|
53
|
+
*
|
|
54
|
+
* @default ExceptionName.Exception
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The error message containing technical informations about the error.
|
|
59
|
+
*
|
|
60
|
+
* It shouldn't be rendered to the user.
|
|
61
|
+
*/
|
|
62
|
+
message?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The error title.
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
title?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The error description.
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
description?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The error code associated with the Exception.
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
code: T;
|
|
78
|
+
/**
|
|
79
|
+
* Indicates whether the error is a critical error.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
isCritical?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The HTTP status code associated with the Exception.
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
status?: number;
|
|
89
|
+
/**
|
|
90
|
+
* The error cause.
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
cause?: unknown;
|
|
16
94
|
}
|
|
17
95
|
/**
|
|
18
96
|
* Exception Class.
|
|
19
97
|
*
|
|
20
|
-
* @template
|
|
21
|
-
* @template TCode The type of the code property of the Exception. Defaults to `ErrorCode`.
|
|
98
|
+
* @template T The type of the code property of the Exception. Defaults to `ErrorCode`.
|
|
22
99
|
*
|
|
23
100
|
* @extends Error
|
|
24
|
-
* @implements ExceptionOptions<
|
|
101
|
+
* @implements ExceptionOptions<T>
|
|
25
102
|
*/
|
|
26
|
-
declare class Exception<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
103
|
+
export declare class Exception<T = ErrorCode> extends Error {
|
|
104
|
+
private readonly __typename;
|
|
105
|
+
/**
|
|
106
|
+
* The error interface name.
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
readonly name: string;
|
|
110
|
+
/**
|
|
111
|
+
* The error message containing technical informations about the error.
|
|
112
|
+
*
|
|
113
|
+
* ⚠️ do not render `Exception.message` to the user.
|
|
114
|
+
*/
|
|
115
|
+
readonly message: string;
|
|
116
|
+
/**
|
|
117
|
+
* The error title that can be rendered to the user.
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
readonly title: string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* The error description that can be rendered to the user.
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
readonly description: string | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* The error code.
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
readonly code: T;
|
|
131
|
+
/**
|
|
132
|
+
* Indicates whether the error is a critical error.
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
readonly isCritical: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* The HTTP status code associated with the Exception.
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
readonly status: number | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* The error cause.
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
readonly cause: unknown;
|
|
146
|
+
/**
|
|
147
|
+
* Constructs a new Exception instance.
|
|
148
|
+
*
|
|
149
|
+
* @param options An object defining Exception options. See {@link ExceptionOptions} for more info.
|
|
150
|
+
*/
|
|
151
|
+
constructor(options: ExceptionOptions<T>);
|
|
152
|
+
/**
|
|
153
|
+
* Determines if the provided error is an instance of the Exception class.
|
|
154
|
+
*
|
|
155
|
+
* @template T The type of the code property of the Exception.
|
|
156
|
+
*
|
|
157
|
+
* @param error The error to check.
|
|
158
|
+
* @returns `true` if the error is an instance of Exception or has a `__typename` property equal to 'Exception', `false` otherwise.
|
|
159
|
+
*/
|
|
160
|
+
static isException<T = ErrorCode>(error: any): error is Exception<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Determines if the provided error is an instance of the Exception class and has the ABORT ErrorCode.
|
|
163
|
+
*
|
|
164
|
+
* @template T The type of the code property of the Exception.
|
|
165
|
+
*
|
|
166
|
+
* @param error The error to check.
|
|
167
|
+
* @returns `true` if the error is an `Exception` and has the ABORT ErrorCode, `false` otherwise.
|
|
168
|
+
*/
|
|
169
|
+
static isAbortError<T = ErrorCode>(error: any, code?: T): error is Exception<T>;
|
|
170
|
+
/**
|
|
171
|
+
* Converts the instance to a JSON object.
|
|
172
|
+
*
|
|
173
|
+
* @returns A JSON representation of the instance, including the message property.
|
|
174
|
+
*/
|
|
175
|
+
toJSON(): this;
|
|
69
176
|
}
|
|
70
|
-
|
|
71
|
-
export { Exception, type ExceptionOptions };
|
|
177
|
+
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ErrorCode as e}from"./code/index.mjs";const t={Exception:`Exception`,AbortError:`AbortError`,NotAllowedError:`NotAllowedError`,NotFoundError:`NotFoundError`,NotSupportedError:`NotSupportedError`,InvalidStateError:`InvalidStateError`,InvalidAccessError:`InvalidAccessError`,NetworkError:`NetworkError`,SecurityError:`SecurityError`,TimeoutError:`TimeoutError`,QuotaExceededError:`QuotaExceededError`,DataError:`DataError`,EncodingError:`EncodingError`,OperationError:`OperationError`,ConstraintError:`ConstraintError`,TransactionInactiveError:`TransactionInactiveError`,ReadOnlyError:`ReadOnlyError`,VersionError:`VersionError`,NoModificationAllowedError:`NoModificationAllowedError`,HierarchyRequestError:`HierarchyRequestError`,WrongDocumentError:`WrongDocumentError`,InvalidCharacterError:`InvalidCharacterError`,NamespaceError:`NamespaceError`,SyntaxError:`SyntaxError`,DataCloneError:`DataCloneError`,URLMismatchError:`URLMismatchError`,InvalidModificationError:`InvalidModificationError`,NotReadableError:`NotReadableError`};var n=class n extends Error{__typename=t.Exception;name=this.__typename;message;title;description;code;isCritical;status;cause;constructor(e){let{message:t=`Unknown error.`}=e;super(t),e.name&&(this.name=e.name),this.message=t,this.title=e.title,this.description=e.description,this.code=e.code,this.isCritical=e.isCritical??!1,this.status=e.status,this.cause=n.isException(e.cause)?new n(e.cause):e.cause}static isException(e){return e instanceof n||typeof e==`object`&&`__typename`in e&&e.__typename===t.Exception}static isAbortError(r,i=e.ABORT){return n.isException(r)&&(r.name===t.AbortError||r.code===i)}toJSON(){return{...this,message:this.message,cause:this.cause}}};export{n as Exception,t as ExceptionName};
|
package/license.md
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alessiofrittoli/exception",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Handle errors with ease",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"author": {
|
|
6
7
|
"name": "Alessio Frittoli",
|
|
7
8
|
"email": "info@alessiofrittoli.it",
|
|
@@ -27,9 +28,13 @@
|
|
|
27
28
|
"type": "git",
|
|
28
29
|
"url": "git+https://github.com/alessiofrittoli/exception.git"
|
|
29
30
|
},
|
|
30
|
-
"
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=24.15.0",
|
|
33
|
+
"pnpm": ">=11.27.1"
|
|
34
|
+
},
|
|
35
|
+
"main": "./dist/index.cjs",
|
|
31
36
|
"module": "./dist/index.mjs",
|
|
32
|
-
"types": "./dist/index.d.
|
|
37
|
+
"types": "./dist/index.d.mts",
|
|
33
38
|
"files": [
|
|
34
39
|
"dist"
|
|
35
40
|
],
|
|
@@ -40,28 +45,18 @@
|
|
|
40
45
|
"default": "./dist/index.mjs"
|
|
41
46
|
},
|
|
42
47
|
"require": {
|
|
43
|
-
"types": "./dist/index.d.
|
|
44
|
-
"default": "./dist/index.
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"./code": {
|
|
48
|
-
"import": {
|
|
49
|
-
"types": "./dist/code.d.mts",
|
|
50
|
-
"default": "./dist/code.mjs"
|
|
51
|
-
},
|
|
52
|
-
"require": {
|
|
53
|
-
"types": "./dist/code.d.ts",
|
|
54
|
-
"default": "./dist/code.js"
|
|
48
|
+
"types": "./dist/index.d.cts",
|
|
49
|
+
"default": "./dist/index.cjs"
|
|
55
50
|
}
|
|
56
51
|
},
|
|
57
|
-
"
|
|
52
|
+
"./*": {
|
|
58
53
|
"import": {
|
|
59
|
-
"types": "./dist
|
|
60
|
-
"default": "./dist
|
|
54
|
+
"types": "./dist/*/index.d.mts",
|
|
55
|
+
"default": "./dist/*/index.mjs"
|
|
61
56
|
},
|
|
62
57
|
"require": {
|
|
63
|
-
"types": "./dist
|
|
64
|
-
"default": "./dist
|
|
58
|
+
"types": "./dist/*/index.d.cts",
|
|
59
|
+
"default": "./dist/*/index.cjs"
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
62
|
},
|
|
@@ -70,43 +65,37 @@
|
|
|
70
65
|
"//1a": "*********************************************************************",
|
|
71
66
|
"//1b": "******************** DEV - BUILD - LINT - RELEASE *******************",
|
|
72
67
|
"//1c": "*********************************************************************",
|
|
73
|
-
"dev": "
|
|
74
|
-
"build
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"release": "node scripts/release.js --verbose --npm",
|
|
68
|
+
"dev": "tsdown --watch",
|
|
69
|
+
"build": "pnpm lint && pnpm tsc && pnpm tsdown",
|
|
70
|
+
"lint": "oxlint --report-unused-disable-directives --max-warnings 0",
|
|
71
|
+
"release": "node scripts/release.ts --verbose --npm",
|
|
78
72
|
"//2a": "*********************************************************************",
|
|
79
73
|
"//2b": "***************************** UNIT TESTS ****************************",
|
|
80
74
|
"//2c": "*********************************************************************",
|
|
81
|
-
"test": "
|
|
82
|
-
"test:watch": "
|
|
83
|
-
"test:ci": "
|
|
75
|
+
"test": "vitest --reporter=tree",
|
|
76
|
+
"test:watch": "pnpm test watch",
|
|
77
|
+
"test:ci": "pnpm test run",
|
|
84
78
|
"//3a": "*********************************************************************",
|
|
85
79
|
"//3b": "************************ UNIT TESTS COVERAGE ************************",
|
|
86
80
|
"//3c": "*********************************************************************",
|
|
87
81
|
"test:coverage": "pnpm test:watch --coverage",
|
|
88
82
|
"test:coverage:ci": "pnpm test:ci --coverage",
|
|
89
|
-
"test:serve-coverage": "http-server ./coverage
|
|
83
|
+
"test:serve-coverage": "http-server ./coverage --gzip true -p 0 -o /index.html --silent",
|
|
90
84
|
"test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\""
|
|
91
85
|
},
|
|
92
86
|
"devDependencies": {
|
|
93
|
-
"@alessiofrittoli/node-scripts": "
|
|
94
|
-
"@
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
97
|
-
"@types/node": "^24.10.1",
|
|
87
|
+
"@alessiofrittoli/node-scripts": "4.0.0-alpha.1",
|
|
88
|
+
"@alessiofrittoli/package-configs": "1.6.0",
|
|
89
|
+
"@types/node": "^24.19.1",
|
|
90
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
98
91
|
"concurrently": "^9.2.1",
|
|
99
|
-
"cross-env": "^10.1.0",
|
|
100
|
-
"dotenv": "^17.2.3",
|
|
101
|
-
"esbuild": "0.27.1",
|
|
102
|
-
"eslint": "^9.39.1",
|
|
103
|
-
"globals": "^16.5.0",
|
|
104
92
|
"http-server": "^14.1.1",
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"typescript": "^
|
|
110
|
-
"
|
|
93
|
+
"oxlint": "^1.86.0",
|
|
94
|
+
"prettier": "^3.9.9",
|
|
95
|
+
"prettier-plugin-sort-imports": "^1.8.11",
|
|
96
|
+
"tsdown": "^0.23.0",
|
|
97
|
+
"typescript": "^6.0.3",
|
|
98
|
+
"vite": "^8.3.2",
|
|
99
|
+
"vitest": "^5.0.3"
|
|
111
100
|
}
|
|
112
101
|
}
|
package/dist/abort.d.mts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ExceptionOptions, Exception } from './index.mjs';
|
|
2
|
-
import { ErrorCode } from './code.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Interface representing the options for an Exception.
|
|
6
|
-
*
|
|
7
|
-
* @extends ExceptionOptions
|
|
8
|
-
*/
|
|
9
|
-
interface AbortErrorOptions<TCode = ErrorCode> extends Partial<Omit<ExceptionOptions<TCode>, 'name'>> {
|
|
10
|
-
/** The HTTP status code associated with the Exception. */
|
|
11
|
-
status?: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Exception Class.
|
|
15
|
-
*
|
|
16
|
-
* @template TMessage The type of the message property of the Exception. Defaults to `string`.
|
|
17
|
-
*
|
|
18
|
-
* @extends Exception
|
|
19
|
-
*/
|
|
20
|
-
declare class AbortError<TMessage = string, TCode = ErrorCode> extends Exception<TMessage, TCode> implements AbortErrorOptions<TCode> {
|
|
21
|
-
constructor(reason: TMessage, options?: AbortErrorOptions<TCode>);
|
|
22
|
-
/**
|
|
23
|
-
* Determines if the provided error is an instance of the AbortError class and has the ABORT ErrorCode.
|
|
24
|
-
*
|
|
25
|
-
* This won't work for `new DOMException( 'Abort reason', 'AbortError' )` since we type guard the checked value to `AbortError<TMessage>`.
|
|
26
|
-
*
|
|
27
|
-
* @template TMessage The type of the message property of the AbortError.
|
|
28
|
-
*
|
|
29
|
-
* @param error The error to check.
|
|
30
|
-
* @returns `true` if the error is an `AbortError` and has the ABORT ErrorCode, `false` otherwise.
|
|
31
|
-
*/
|
|
32
|
-
static isAbortError<TMessage = string, TCode = ErrorCode>(error: any, code?: TCode): error is AbortError<TMessage, TCode>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { AbortError, type AbortErrorOptions };
|
package/dist/abort.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ExceptionOptions, Exception } from './index.js';
|
|
2
|
-
import { ErrorCode } from './code.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Interface representing the options for an Exception.
|
|
6
|
-
*
|
|
7
|
-
* @extends ExceptionOptions
|
|
8
|
-
*/
|
|
9
|
-
interface AbortErrorOptions<TCode = ErrorCode> extends Partial<Omit<ExceptionOptions<TCode>, 'name'>> {
|
|
10
|
-
/** The HTTP status code associated with the Exception. */
|
|
11
|
-
status?: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Exception Class.
|
|
15
|
-
*
|
|
16
|
-
* @template TMessage The type of the message property of the Exception. Defaults to `string`.
|
|
17
|
-
*
|
|
18
|
-
* @extends Exception
|
|
19
|
-
*/
|
|
20
|
-
declare class AbortError<TMessage = string, TCode = ErrorCode> extends Exception<TMessage, TCode> implements AbortErrorOptions<TCode> {
|
|
21
|
-
constructor(reason: TMessage, options?: AbortErrorOptions<TCode>);
|
|
22
|
-
/**
|
|
23
|
-
* Determines if the provided error is an instance of the AbortError class and has the ABORT ErrorCode.
|
|
24
|
-
*
|
|
25
|
-
* This won't work for `new DOMException( 'Abort reason', 'AbortError' )` since we type guard the checked value to `AbortError<TMessage>`.
|
|
26
|
-
*
|
|
27
|
-
* @template TMessage The type of the message property of the AbortError.
|
|
28
|
-
*
|
|
29
|
-
* @param error The error to check.
|
|
30
|
-
* @returns `true` if the error is an `AbortError` and has the ABORT ErrorCode, `false` otherwise.
|
|
31
|
-
*/
|
|
32
|
-
static isAbortError<TMessage = string, TCode = ErrorCode>(error: any, code?: TCode): error is AbortError<TMessage, TCode>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { AbortError, type AbortErrorOptions };
|
package/dist/abort.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOBRRZX4Djs = require('./chunk-OBRRZX4D.js');var _chunkPSRQLNM6js = require('./chunk-PSRQLNM6.js');var s=class extends _chunkOBRRZX4Djs.a{constructor(r,o={}){let n="AbortError",{code:i=_chunkPSRQLNM6js.a.ABORT,...d}=o;super(r,{...d,name:n,code:i})}static isAbortError(r,o){return super.isAbortError(r,o)}};exports.AbortError = s;
|
package/dist/abort.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-RAHIXT6K.mjs";import{a as e}from"./chunk-VBWDYSF3.mjs";var s=class extends t{constructor(r,o={}){let n="AbortError",{code:i=e.ABORT,...d}=o;super(r,{...d,name:n,code:i})}static isAbortError(r,o){return super.isAbortError(r,o)}};export{s as AbortError};
|
package/dist/chunk-OBRRZX4D.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPSRQLNM6js = require('./chunk-PSRQLNM6.js');var r=class t extends Error{constructor(e,s){super("",s),this.__typename="Exception",this.name=s.name||this.__typename,this.message=e,this.code=s.code,this.status=s.status}static isException(e){return e instanceof t||typeof e=="object"&&"__typename"in e&&e.__typename==="Exception"}static isAbortError(e,s=_chunkPSRQLNM6js.a.ABORT){return t.isException(e)&&(e.name==="AbortError"||e.code===s)}toJSON(){return{...this,message:this.message,cause:this.cause}}};exports.a = r;
|
package/dist/chunk-PSRQLNM6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var R={UNKNOWN:"ERR:UNKNOWN",ABORT:"ERR:ABORT",EMPTY_VALUE:"ERR:EMPTYVALUE",WRONG_VALUE:"ERR:WRONGVALUE",EXPIRED:"ERR:EXPIRED",TOO_EARLY:"ERR:TOOEARLY",TOO_MANY:"ERR:TOOMANY",QUOTA_REACHED:"ERR:QUOTAREACHED",NOT_FOUND:"ERR:NOTFOUND",OFFLINE:"ERR:INTERNETDISCONNECTED"};exports.a = R;
|
package/dist/chunk-RAHIXT6K.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-VBWDYSF3.mjs";var r=class t extends Error{constructor(e,s){super("",s),this.__typename="Exception",this.name=s.name||this.__typename,this.message=e,this.code=s.code,this.status=s.status}static isException(e){return e instanceof t||typeof e=="object"&&"__typename"in e&&e.__typename==="Exception"}static isAbortError(e,s=o.ABORT){return t.isException(e)&&(e.name==="AbortError"||e.code===s)}toJSON(){return{...this,message:this.message,cause:this.cause}}};export{r as a};
|
package/dist/chunk-VBWDYSF3.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var O={UNKNOWN:"ERR:UNKNOWN",ABORT:"ERR:ABORT",EMPTY_VALUE:"ERR:EMPTYVALUE",WRONG_VALUE:"ERR:WRONGVALUE",EXPIRED:"ERR:EXPIRED",TOO_EARLY:"ERR:TOOEARLY",TOO_MANY:"ERR:TOOMANY",QUOTA_REACHED:"ERR:QUOTAREACHED",NOT_FOUND:"ERR:NOTFOUND",OFFLINE:"ERR:INTERNETDISCONNECTED"};export{O as a};
|
package/dist/code.d.mts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Most common error codes.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
declare const ErrorCode: {
|
|
6
|
-
readonly UNKNOWN: "ERR:UNKNOWN";
|
|
7
|
-
readonly ABORT: "ERR:ABORT";
|
|
8
|
-
readonly EMPTY_VALUE: "ERR:EMPTYVALUE";
|
|
9
|
-
readonly WRONG_VALUE: "ERR:WRONGVALUE";
|
|
10
|
-
readonly EXPIRED: "ERR:EXPIRED";
|
|
11
|
-
readonly TOO_EARLY: "ERR:TOOEARLY";
|
|
12
|
-
readonly TOO_MANY: "ERR:TOOMANY";
|
|
13
|
-
readonly QUOTA_REACHED: "ERR:QUOTAREACHED";
|
|
14
|
-
readonly NOT_FOUND: "ERR:NOTFOUND";
|
|
15
|
-
readonly OFFLINE: "ERR:INTERNETDISCONNECTED";
|
|
16
|
-
};
|
|
17
|
-
type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
18
|
-
|
|
19
|
-
export { ErrorCode };
|