@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.
@@ -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
- // Stack includes message
49
- s = obj.stack;
50
- }
51
- else {
52
- // Omit "default" error name as non-informative
53
- // UPD: no, it's still important to understand that we're dealing with Error and not just some string
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
- // Stack includes message
46
- s = obj.stack;
47
- }
48
- else {
49
- // Omit "default" error name as non-informative
50
- // UPD: no, it's still important to understand that we're dealing with Error and not just some string
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.75.0",
3
+ "version": "14.75.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -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
- // Stack includes message
81
- s = obj.stack
82
- } else {
83
- // Omit "default" error name as non-informative
84
- // UPD: no, it's still important to understand that we're dealing with Error and not just some string
85
- // if (obj?.name === 'Error') {
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)) {