@util.js/errors 0.41.4 → 0.41.5
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 +1 -1
- package/doc/README-examples.js +2 -2
- package/lib/AsyncError.js +2 -2
- package/lib/FalsyError.js +1 -1
- package/lib/MissingError.js +1 -1
- package/lib/RethrownError.js +1 -1
- package/package.json +1 -2
- package/test/ErrorsTest.js +9 -9
- package/test/Errors_FalsyError_check_Test.js +4 -4
package/README.md
CHANGED
|
@@ -153,7 +153,7 @@ errors
|
|
|
153
153
|
// at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
|
|
154
154
|
|
|
155
155
|
rejectAPromise().catch((error) =>
|
|
156
|
-
console.log("\n\nWithout Caller Stack Trace\n" + error.stack)
|
|
156
|
+
console.log("\n\nWithout Caller Stack Trace\n" + error.stack),
|
|
157
157
|
);
|
|
158
158
|
// Without Caller Stack Trace
|
|
159
159
|
// TypeError: Fail!
|
package/doc/README-examples.js
CHANGED
|
@@ -23,7 +23,7 @@ function runExample0() {
|
|
|
23
23
|
errors
|
|
24
24
|
.catch(rejectAPromise())
|
|
25
25
|
.catch((error) =>
|
|
26
|
-
console.log("\n\nWith Caller Stack Trace\n" + error.stack)
|
|
26
|
+
console.log("\n\nWith Caller Stack Trace\n" + error.stack),
|
|
27
27
|
);
|
|
28
28
|
// With Caller Stack Trace
|
|
29
29
|
// AsyncError: Fail!
|
|
@@ -54,7 +54,7 @@ function runExample0() {
|
|
|
54
54
|
// at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
|
|
55
55
|
|
|
56
56
|
rejectAPromise().catch((error) =>
|
|
57
|
-
console.log("\n\nWithout Caller Stack Trace\n" + error.stack)
|
|
57
|
+
console.log("\n\nWithout Caller Stack Trace\n" + error.stack),
|
|
58
58
|
);
|
|
59
59
|
// Without Caller Stack Trace
|
|
60
60
|
// TypeError: Fail!
|
package/lib/AsyncError.js
CHANGED
|
@@ -8,11 +8,11 @@ module.exports = class AsyncError extends Error {
|
|
|
8
8
|
super(message != null ? message : getErrorProperty(asyncError, "message"));
|
|
9
9
|
if (!callerError)
|
|
10
10
|
throw new TypeError(
|
|
11
|
-
`${this.constructor.name}'s constructor expects a defined callerError, but it was ${callerError}
|
|
11
|
+
`${this.constructor.name}'s constructor expects a defined callerError, but it was ${callerError}.`,
|
|
12
12
|
);
|
|
13
13
|
if (!asyncError)
|
|
14
14
|
throw new TypeError(
|
|
15
|
-
`${this.constructor.name}'s constructor expects a defined asyncError, but it was ${asyncError}
|
|
15
|
+
`${this.constructor.name}'s constructor expects a defined asyncError, but it was ${asyncError}.`,
|
|
16
16
|
);
|
|
17
17
|
this.name = this.constructor.name;
|
|
18
18
|
this.original = asyncError;
|
package/lib/FalsyError.js
CHANGED
|
@@ -19,7 +19,7 @@ module.exports = class FalsyError extends TypeError {
|
|
|
19
19
|
(argumentName ? "`" + argumentName + "`" : "It") +
|
|
20
20
|
" is the falsy value " +
|
|
21
21
|
(argumentValue === "" ? "''" : argumentValue) +
|
|
22
|
-
"."
|
|
22
|
+
".",
|
|
23
23
|
);
|
|
24
24
|
this.name = this.constructor.name;
|
|
25
25
|
this.argumentName = argumentName;
|
package/lib/MissingError.js
CHANGED
package/lib/RethrownError.js
CHANGED
|
@@ -8,7 +8,7 @@ module.exports = class RethrownError extends Error {
|
|
|
8
8
|
super(message != null ? message : getErrorProperty(error, "message"));
|
|
9
9
|
if (!error)
|
|
10
10
|
throw new TypeError(
|
|
11
|
-
`RethrownError's constructor expects a defined error, but it was ${error}
|
|
11
|
+
`RethrownError's constructor expects a defined error, but it was ${error}.`,
|
|
12
12
|
);
|
|
13
13
|
this.name = this.constructor.name;
|
|
14
14
|
this.original = error;
|
package/package.json
CHANGED
package/test/ErrorsTest.js
CHANGED
|
@@ -83,10 +83,10 @@ describe("new Errors#RethrownError(message, error)", () => {
|
|
|
83
83
|
throwATypeError();
|
|
84
84
|
} catch (error) {
|
|
85
85
|
expect(new RethrownError(error).stack).to.include(
|
|
86
|
-
"RethrownError: Invalid Argument\n"
|
|
86
|
+
"RethrownError: Invalid Argument\n",
|
|
87
87
|
);
|
|
88
88
|
expect(new RethrownError(error, "").stack).to.include(
|
|
89
|
-
"RethrownError\n"
|
|
89
|
+
"RethrownError\n",
|
|
90
90
|
);
|
|
91
91
|
throw new RethrownError(error, "Lorem Ipsum");
|
|
92
92
|
}
|
|
@@ -114,18 +114,18 @@ describe("new Errors#RethrownError(message, error)", () => {
|
|
|
114
114
|
throwAString();
|
|
115
115
|
} catch (error) {
|
|
116
116
|
expect(new RethrownError(error).stack).to.include(
|
|
117
|
-
'RethrownError: "ENTITY_NOT_FOUND"\n'
|
|
117
|
+
'RethrownError: "ENTITY_NOT_FOUND"\n',
|
|
118
118
|
);
|
|
119
119
|
expect(new RethrownError(error).stack.endsWith('"ENTITY_NOT_FOUND"')).to
|
|
120
120
|
.be.true;
|
|
121
121
|
expect(new RethrownError(error, "").stack).to.include(
|
|
122
|
-
"RethrownError\n"
|
|
122
|
+
"RethrownError\n",
|
|
123
123
|
);
|
|
124
124
|
expect(new RethrownError(error, 0).stack).to.include(
|
|
125
|
-
"RethrownError: 0\n"
|
|
125
|
+
"RethrownError: 0\n",
|
|
126
126
|
);
|
|
127
127
|
expect(new RethrownError(error, "").stack).to.include(
|
|
128
|
-
"ENTITY_NOT_FOUND"
|
|
128
|
+
"ENTITY_NOT_FOUND",
|
|
129
129
|
);
|
|
130
130
|
throw new RethrownError(error, "Lorem Ipsum");
|
|
131
131
|
}
|
|
@@ -152,15 +152,15 @@ describe("new Errors#RethrownError(message, error)", () => {
|
|
|
152
152
|
throwAnArray();
|
|
153
153
|
} catch (error) {
|
|
154
154
|
expect(new RethrownError(error).stack).to.include(
|
|
155
|
-
'RethrownError: [{"code":"1234"}]\n'
|
|
155
|
+
'RethrownError: [{"code":"1234"}]\n',
|
|
156
156
|
);
|
|
157
157
|
expect(new RethrownError(error).stack.endsWith('[{"code":"1234"}]')).to
|
|
158
158
|
.be.true;
|
|
159
159
|
expect(new RethrownError(error, "").stack).to.include(
|
|
160
|
-
"RethrownError\n"
|
|
160
|
+
"RethrownError\n",
|
|
161
161
|
);
|
|
162
162
|
expect(new RethrownError(error, "").stack).to.include(
|
|
163
|
-
'[{"code":"1234"}]'
|
|
163
|
+
'[{"code":"1234"}]',
|
|
164
164
|
);
|
|
165
165
|
throw new RethrownError(error, "Lorem Ipsum");
|
|
166
166
|
}
|
|
@@ -11,7 +11,7 @@ describe("FalsyError#check", () => {
|
|
|
11
11
|
} catch (e) {
|
|
12
12
|
expect(e).to.be.an.instanceof(FalsyError);
|
|
13
13
|
expect(e.message).to.equal(
|
|
14
|
-
"Lawyer#argue expected `argument` to be truthy. `argument` is the falsy value NaN."
|
|
14
|
+
"Lawyer#argue expected `argument` to be truthy. `argument` is the falsy value NaN.",
|
|
15
15
|
);
|
|
16
16
|
expect(e.argumentName).to.equal("argument");
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ describe("FalsyError#check", () => {
|
|
|
24
24
|
} catch (e) {
|
|
25
25
|
expect(e).to.be.an.instanceof(FalsyError);
|
|
26
26
|
expect(e.message).to.equal(
|
|
27
|
-
"We expected `argument` to be truthy. `argument` is the falsy value false."
|
|
27
|
+
"We expected `argument` to be truthy. `argument` is the falsy value false.",
|
|
28
28
|
);
|
|
29
29
|
expect(e.argumentName).to.equal("argument");
|
|
30
30
|
}
|
|
@@ -37,7 +37,7 @@ describe("FalsyError#check", () => {
|
|
|
37
37
|
} catch (e) {
|
|
38
38
|
expect(e).to.be.an.instanceof(FalsyError);
|
|
39
39
|
expect(e.message).to.equal(
|
|
40
|
-
"Lawyer#argue expected an argument to be truthy. It is the falsy value undefined."
|
|
40
|
+
"Lawyer#argue expected an argument to be truthy. It is the falsy value undefined.",
|
|
41
41
|
);
|
|
42
42
|
expect(e.argumentName).to.be.null;
|
|
43
43
|
}
|
|
@@ -50,7 +50,7 @@ describe("FalsyError#check", () => {
|
|
|
50
50
|
} catch (e) {
|
|
51
51
|
expect(e).to.be.an.instanceof(FalsyError);
|
|
52
52
|
expect(e.message).to.equal(
|
|
53
|
-
"We expected an argument to be truthy. It is the falsy value null."
|
|
53
|
+
"We expected an argument to be truthy. It is the falsy value null.",
|
|
54
54
|
);
|
|
55
55
|
expect(e.argumentName).to.be.undefined;
|
|
56
56
|
}
|