@naturalcycles/js-lib 14.133.0 → 14.133.1
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/error/app.error.d.ts +1 -1
- package/dist/error/app.error.js +9 -2
- package/dist/error/assert.d.ts +1 -0
- package/dist/error/assert.js +3 -0
- package/dist/error/error.util.js +6 -0
- package/dist/error/http.error.js +1 -1
- package/dist/promise/pTimeout.d.ts +1 -0
- package/dist/promise/pTimeout.js +3 -0
- package/dist-esm/error/app.error.js +9 -2
- package/dist-esm/error/assert.js +3 -0
- package/dist-esm/error/error.util.js +6 -0
- package/dist-esm/error/http.error.js +1 -1
- package/dist-esm/promise/pTimeout.js +3 -0
- package/package.json +1 -1
- package/src/error/app.error.ts +10 -2
- package/src/error/assert.ts +5 -1
- package/src/error/error.util.ts +7 -0
- package/src/error/http.error.ts +1 -1
- package/src/promise/pTimeout.ts +5 -1
|
@@ -14,5 +14,5 @@ export declare class AppError<DATA_TYPE extends ErrorData = ErrorData> extends E
|
|
|
14
14
|
* cause here is normalized to be instance of Error
|
|
15
15
|
*/
|
|
16
16
|
cause?: Error;
|
|
17
|
-
constructor(message: string, data?: DATA_TYPE, opt?: ErrorOptions);
|
|
17
|
+
constructor(message: string, data?: DATA_TYPE, opt?: ErrorOptions, name?: string);
|
|
18
18
|
}
|
package/dist/error/app.error.js
CHANGED
|
@@ -11,11 +11,18 @@ exports.AppError = void 0;
|
|
|
11
11
|
* Based on: https://medium.com/@xpl/javascript-deriving-from-error-properly-8d2f8f315801
|
|
12
12
|
*/
|
|
13
13
|
class AppError extends Error {
|
|
14
|
-
constructor(message, data = {}, opt) {
|
|
14
|
+
constructor(message, data = {}, opt, name) {
|
|
15
15
|
super(message);
|
|
16
16
|
Object.defineProperty(this, 'name', {
|
|
17
|
-
value: this.constructor.name,
|
|
17
|
+
value: name || this.constructor.name,
|
|
18
18
|
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
});
|
|
21
|
+
// this is to allow changing this.constuctor.name to a non-minified version
|
|
22
|
+
Object.defineProperty(this.constructor, 'name', {
|
|
23
|
+
value: name || this.constructor.name,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
19
26
|
});
|
|
20
27
|
Object.defineProperty(this, 'data', {
|
|
21
28
|
value: data,
|
package/dist/error/assert.d.ts
CHANGED
|
@@ -36,4 +36,5 @@ export declare function _assertIsString(v: any, message?: string): asserts v is
|
|
|
36
36
|
export declare function _assertIsNumber(v: any, message?: string): asserts v is number;
|
|
37
37
|
export declare function _assertTypeOf<T>(v: any, expectedType: string, message?: string): asserts v is T;
|
|
38
38
|
export declare class AssertionError extends AppError {
|
|
39
|
+
constructor(message: string, data?: {}, opt?: ErrorOptions);
|
|
39
40
|
}
|
package/dist/error/assert.js
CHANGED
|
@@ -103,5 +103,8 @@ function _assertTypeOf(v, expectedType, message) {
|
|
|
103
103
|
}
|
|
104
104
|
exports._assertTypeOf = _assertTypeOf;
|
|
105
105
|
class AssertionError extends app_error_1.AppError {
|
|
106
|
+
constructor(message, data = {}, opt) {
|
|
107
|
+
super(message, data, opt, 'AssertionError');
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
exports.AssertionError = AssertionError;
|
package/dist/error/error.util.js
CHANGED
|
@@ -88,6 +88,12 @@ function _errorObjectToError(o, errorClass = Error) {
|
|
|
88
88
|
Object.defineProperty(err, 'name', {
|
|
89
89
|
value: o.name,
|
|
90
90
|
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(err.constructor, 'name', {
|
|
94
|
+
value: o.name,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true,
|
|
91
97
|
});
|
|
92
98
|
Object.defineProperty(err, 'data', {
|
|
93
99
|
value: o.data,
|
package/dist/error/http.error.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AppError } from '../error/app.error';
|
|
|
2
2
|
import type { ErrorData } from '../error/error.model';
|
|
3
3
|
import type { AnyAsyncFunction } from '../types';
|
|
4
4
|
export declare class TimeoutError extends AppError {
|
|
5
|
+
constructor(message: string, data?: {}, opt?: ErrorOptions);
|
|
5
6
|
}
|
|
6
7
|
export interface PTimeoutOptions {
|
|
7
8
|
/**
|
package/dist/promise/pTimeout.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pTimeout = exports.pTimeoutFn = exports.TimeoutError = void 0;
|
|
4
4
|
const app_error_1 = require("../error/app.error");
|
|
5
5
|
class TimeoutError extends app_error_1.AppError {
|
|
6
|
+
constructor(message, data = {}, opt) {
|
|
7
|
+
super(message, data, opt, 'TimeoutError');
|
|
8
|
+
}
|
|
6
9
|
}
|
|
7
10
|
exports.TimeoutError = TimeoutError;
|
|
8
11
|
/**
|
|
@@ -8,11 +8,18 @@
|
|
|
8
8
|
* Based on: https://medium.com/@xpl/javascript-deriving-from-error-properly-8d2f8f315801
|
|
9
9
|
*/
|
|
10
10
|
export class AppError extends Error {
|
|
11
|
-
constructor(message, data = {}, opt) {
|
|
11
|
+
constructor(message, data = {}, opt, name) {
|
|
12
12
|
super(message);
|
|
13
13
|
Object.defineProperty(this, 'name', {
|
|
14
|
-
value: this.constructor.name,
|
|
14
|
+
value: name || this.constructor.name,
|
|
15
15
|
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
});
|
|
18
|
+
// this is to allow changing this.constuctor.name to a non-minified version
|
|
19
|
+
Object.defineProperty(this.constructor, 'name', {
|
|
20
|
+
value: name || this.constructor.name,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
16
23
|
});
|
|
17
24
|
Object.defineProperty(this, 'data', {
|
|
18
25
|
value: data,
|
package/dist-esm/error/assert.js
CHANGED
|
@@ -79,6 +79,12 @@ export function _errorObjectToError(o, errorClass = Error) {
|
|
|
79
79
|
Object.defineProperty(err, 'name', {
|
|
80
80
|
value: o.name,
|
|
81
81
|
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(err.constructor, 'name', {
|
|
85
|
+
value: o.name,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
82
88
|
});
|
|
83
89
|
Object.defineProperty(err, 'data', {
|
|
84
90
|
value: o.data,
|
package/package.json
CHANGED
package/src/error/app.error.ts
CHANGED
|
@@ -17,12 +17,20 @@ export class AppError<DATA_TYPE extends ErrorData = ErrorData> extends Error {
|
|
|
17
17
|
*/
|
|
18
18
|
override cause?: Error
|
|
19
19
|
|
|
20
|
-
constructor(message: string, data = {} as DATA_TYPE, opt?: ErrorOptions) {
|
|
20
|
+
constructor(message: string, data = {} as DATA_TYPE, opt?: ErrorOptions, name?: string) {
|
|
21
21
|
super(message)
|
|
22
22
|
|
|
23
23
|
Object.defineProperty(this, 'name', {
|
|
24
|
-
value: this.constructor.name,
|
|
24
|
+
value: name || this.constructor.name,
|
|
25
25
|
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// this is to allow changing this.constuctor.name to a non-minified version
|
|
30
|
+
Object.defineProperty(this.constructor, 'name', {
|
|
31
|
+
value: name || this.constructor.name,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
26
34
|
})
|
|
27
35
|
|
|
28
36
|
Object.defineProperty(this, 'data', {
|
package/src/error/assert.ts
CHANGED
|
@@ -123,4 +123,8 @@ export function _assertTypeOf<T>(v: any, expectedType: string, message?: string)
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export class AssertionError extends AppError {
|
|
126
|
+
export class AssertionError extends AppError {
|
|
127
|
+
constructor(message: string, data = {}, opt?: ErrorOptions) {
|
|
128
|
+
super(message, data, opt, 'AssertionError')
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/error/error.util.ts
CHANGED
|
@@ -105,6 +105,13 @@ export function _errorObjectToError<DATA_TYPE extends ErrorData, ERROR_TYPE exte
|
|
|
105
105
|
Object.defineProperty(err, 'name', {
|
|
106
106
|
value: o.name,
|
|
107
107
|
configurable: true,
|
|
108
|
+
writable: true,
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
Object.defineProperty(err.constructor, 'name', {
|
|
112
|
+
value: o.name,
|
|
113
|
+
configurable: true,
|
|
114
|
+
writable: true,
|
|
108
115
|
})
|
|
109
116
|
|
|
110
117
|
Object.defineProperty(err, 'data', {
|
package/src/error/http.error.ts
CHANGED
package/src/promise/pTimeout.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { AppError } from '../error/app.error'
|
|
|
2
2
|
import type { ErrorData } from '../error/error.model'
|
|
3
3
|
import type { AnyAsyncFunction } from '../types'
|
|
4
4
|
|
|
5
|
-
export class TimeoutError extends AppError {
|
|
5
|
+
export class TimeoutError extends AppError {
|
|
6
|
+
constructor(message: string, data = {}, opt?: ErrorOptions) {
|
|
7
|
+
super(message, data, opt, 'TimeoutError')
|
|
8
|
+
}
|
|
9
|
+
}
|
|
6
10
|
|
|
7
11
|
export interface PTimeoutOptions {
|
|
8
12
|
/**
|