@augment-vir/core 31.51.1 → 31.53.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.
|
@@ -7,5 +7,11 @@
|
|
|
7
7
|
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
8
8
|
*/
|
|
9
9
|
export declare function extractErrorMessage(maybeError: unknown): string;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Combines multiple error messages into a single error message.
|
|
12
|
+
*
|
|
13
|
+
* @category Error
|
|
14
|
+
* @category Package : @augment-vir/common
|
|
15
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
16
|
+
*/
|
|
17
|
+
export declare function combineErrorMessages(...rawMessages: ReadonlyArray<unknown>): string;
|
|
@@ -9,18 +9,18 @@ import { removeEndingPunctuation } from '../string/punctuation.js';
|
|
|
9
9
|
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
10
10
|
*/
|
|
11
11
|
export function extractErrorMessage(maybeError) {
|
|
12
|
-
if (
|
|
12
|
+
if (maybeError == undefined || maybeError === '') {
|
|
13
13
|
return '';
|
|
14
14
|
}
|
|
15
|
-
if (maybeError
|
|
15
|
+
if (typeof maybeError === 'string') {
|
|
16
|
+
return maybeError;
|
|
17
|
+
}
|
|
18
|
+
else if (maybeError instanceof Error) {
|
|
16
19
|
return maybeError.message;
|
|
17
20
|
}
|
|
18
21
|
else if (typeof maybeError === 'object' && 'message' in maybeError) {
|
|
19
22
|
return String(maybeError.message);
|
|
20
23
|
}
|
|
21
|
-
else if (typeof maybeError === 'string') {
|
|
22
|
-
return maybeError;
|
|
23
|
-
}
|
|
24
24
|
else {
|
|
25
25
|
return stringify(maybeError);
|
|
26
26
|
}
|
|
@@ -33,24 +33,13 @@ export function extractErrorMessage(maybeError) {
|
|
|
33
33
|
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
34
34
|
*/
|
|
35
35
|
export function combineErrorMessages(...rawMessages) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
else if (!messages.length) {
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
const unPunctuatedMessages = messages.map((message, index) => {
|
|
47
|
-
if (index === messages.length - 1) {
|
|
48
|
-
/** Preserve punctuation on the last message. */
|
|
49
|
-
return message;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return removeEndingPunctuation(message);
|
|
53
|
-
}
|
|
36
|
+
const truthyMessageStrings = rawMessages
|
|
37
|
+
.map((message) => extractErrorMessage(message))
|
|
38
|
+
.filter((message) => !!removeEndingPunctuation(message));
|
|
39
|
+
const hasTrailingPeriod = truthyMessageStrings[truthyMessageStrings.length - 1]?.endsWith('.');
|
|
40
|
+
const messages = truthyMessageStrings.map((message) => {
|
|
41
|
+
return removeEndingPunctuation(extractErrorMessage(message));
|
|
54
42
|
});
|
|
55
|
-
|
|
43
|
+
const combinedMessage = messages.length < 2 ? messages[0] || '' : messages.join(': ');
|
|
44
|
+
return combinedMessage + (hasTrailingPeriod ? '.' : '');
|
|
56
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/core",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.53.0",
|
|
4
4
|
"description": "Core augment-vir augments. Use @augment-vir/common instead.",
|
|
5
5
|
"homepage": "https://github.com/electrovir/augment-vir",
|
|
6
6
|
"bugs": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"type-fest": "^5.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^24.10.
|
|
38
|
+
"@types/node": "^24.10.1",
|
|
39
39
|
"c8": "^10.1.3",
|
|
40
40
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
41
41
|
"typescript": "^5.9.3"
|