@naturalcycles/js-lib 14.75.0 → 14.75.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/string/stringifyAny.js +12 -10
- package/dist-esm/string/stringifyAny.js +12 -10
- package/package.json +1 -1
- package/src/string/stringifyAny.ts +13 -9
|
@@ -44,17 +44,19 @@ function _stringifyAny(obj, opt = {}) {
|
|
|
44
44
|
//
|
|
45
45
|
// Error or ErrorObject
|
|
46
46
|
//
|
|
47
|
+
// Omit "default" error name as non-informative
|
|
48
|
+
// UPD: no, it's still important to understand that we're dealing with Error and not just some string
|
|
49
|
+
// if (obj?.name === 'Error') {
|
|
50
|
+
// s = obj.message
|
|
51
|
+
// }
|
|
52
|
+
s = [obj.name, obj.message].join(': ');
|
|
47
53
|
if (opt.includeErrorStack && obj.stack) {
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
// if (obj?.name === 'Error') {
|
|
55
|
-
// s = obj.message
|
|
56
|
-
// }
|
|
57
|
-
s = [obj.name, obj.message].join(': ');
|
|
54
|
+
// Here we're using the previously-generated "title line" (e.g "Error: some_message"),
|
|
55
|
+
// concatenating it with the Stack (but without the title line of the Stack)
|
|
56
|
+
// This is to fix the rare error (happened with Got) where `err.message` was changed,
|
|
57
|
+
// but err.stack had "old" err.message
|
|
58
|
+
// This should "fix" that
|
|
59
|
+
s = [s, ...obj.stack.split('\n').slice(1)].join('\n');
|
|
58
60
|
}
|
|
59
61
|
if ((0, error_util_1._isErrorObject)(obj)) {
|
|
60
62
|
if ((0, error_util_1._isHttpErrorObject)(obj)) {
|
|
@@ -41,17 +41,19 @@ export function _stringifyAny(obj, opt = {}) {
|
|
|
41
41
|
//
|
|
42
42
|
// Error or ErrorObject
|
|
43
43
|
//
|
|
44
|
+
// Omit "default" error name as non-informative
|
|
45
|
+
// UPD: no, it's still important to understand that we're dealing with Error and not just some string
|
|
46
|
+
// if (obj?.name === 'Error') {
|
|
47
|
+
// s = obj.message
|
|
48
|
+
// }
|
|
49
|
+
s = [obj.name, obj.message].join(': ');
|
|
44
50
|
if (opt.includeErrorStack && obj.stack) {
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
// if (obj?.name === 'Error') {
|
|
52
|
-
// s = obj.message
|
|
53
|
-
// }
|
|
54
|
-
s = [obj.name, obj.message].join(': ');
|
|
51
|
+
// Here we're using the previously-generated "title line" (e.g "Error: some_message"),
|
|
52
|
+
// concatenating it with the Stack (but without the title line of the Stack)
|
|
53
|
+
// This is to fix the rare error (happened with Got) where `err.message` was changed,
|
|
54
|
+
// but err.stack had "old" err.message
|
|
55
|
+
// This should "fix" that
|
|
56
|
+
s = [s, ...obj.stack.split('\n').slice(1)].join('\n');
|
|
55
57
|
}
|
|
56
58
|
if (_isErrorObject(obj)) {
|
|
57
59
|
if (_isHttpErrorObject(obj)) {
|
package/package.json
CHANGED
|
@@ -76,16 +76,20 @@ export function _stringifyAny(obj: any, opt: StringifyAnyOptions = {}): string {
|
|
|
76
76
|
// Error or ErrorObject
|
|
77
77
|
//
|
|
78
78
|
|
|
79
|
+
// Omit "default" error name as non-informative
|
|
80
|
+
// UPD: no, it's still important to understand that we're dealing with Error and not just some string
|
|
81
|
+
// if (obj?.name === 'Error') {
|
|
82
|
+
// s = obj.message
|
|
83
|
+
// }
|
|
84
|
+
s = [obj.name, obj.message].join(': ')
|
|
85
|
+
|
|
79
86
|
if (opt.includeErrorStack && obj.stack) {
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
// s = obj.message
|
|
87
|
-
// }
|
|
88
|
-
s = [obj.name, obj.message].join(': ')
|
|
87
|
+
// Here we're using the previously-generated "title line" (e.g "Error: some_message"),
|
|
88
|
+
// concatenating it with the Stack (but without the title line of the Stack)
|
|
89
|
+
// This is to fix the rare error (happened with Got) where `err.message` was changed,
|
|
90
|
+
// but err.stack had "old" err.message
|
|
91
|
+
// This should "fix" that
|
|
92
|
+
s = [s, ...obj.stack.split('\n').slice(1)].join('\n')
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
if (_isErrorObject(obj)) {
|