@naturalcycles/js-lib 14.167.0 → 14.168.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.
@@ -48,14 +48,6 @@ export interface ErrorData {
48
48
  * Sentry takes string[], but for convenience we allow to pass a singe string.
49
49
  */
50
50
  fingerprint?: string | string[];
51
- /**
52
- * If set to true - it'll use error.message as fingerprint,
53
- * so, all errors with the same message will be grouped together, even if they occurred in different places.
54
- * Defaults to false.
55
- *
56
- * @experimental
57
- */
58
- fingerprintByMessage?: boolean;
59
51
  /**
60
52
  * Set when throwing an error from your backend code, to indicate desired http status code.
61
53
  * e.g throw new AppError('oj', { backendResponseStatusCode: 401 })
@@ -32,6 +32,12 @@ export interface StringifyAnyOptions {
32
32
  * @default true
33
33
  */
34
34
  includeErrorCause?: boolean;
35
+ /**
36
+ * Set to true to include Error.data.
37
+ *
38
+ * @default false
39
+ */
40
+ includeErrorData?: boolean;
35
41
  /**
36
42
  * Allows to pass custom "stringify function".
37
43
  * E.g in Node.js you can pass `util.inspect` instead.
@@ -78,6 +78,9 @@ function _stringifyAny(obj, opt = {}) {
78
78
  // Error that has no `data`, but has `code` property
79
79
  s += `\ncode: ${obj.code}`;
80
80
  }
81
+ if (opt.includeErrorData && (0, error_util_1._isErrorObject)(obj)) {
82
+ s += '\n' + _stringifyAny(obj.data, opt);
83
+ }
81
84
  if (opt.includeErrorStack && obj.stack) {
82
85
  // Here we're using the previously-generated "title line" (e.g "Error: some_message"),
83
86
  // concatenating it with the Stack (but without the title line of the Stack)
@@ -1,4 +1,4 @@
1
- import { _isBackendErrorResponseObject, _isErrorLike } from '../error/error.util';
1
+ import { _isBackendErrorResponseObject, _isErrorLike, _isErrorObject } from '../error/error.util';
2
2
  import { _jsonParseIfPossible } from './json.util';
3
3
  import { _safeJsonStringify } from './safeJsonStringify';
4
4
  const supportsAggregateError = typeof globalThis.AggregateError === 'function';
@@ -74,6 +74,9 @@ export function _stringifyAny(obj, opt = {}) {
74
74
  // Error that has no `data`, but has `code` property
75
75
  s += `\ncode: ${obj.code}`;
76
76
  }
77
+ if (opt.includeErrorData && _isErrorObject(obj)) {
78
+ s += '\n' + _stringifyAny(obj.data, opt);
79
+ }
77
80
  if (opt.includeErrorStack && obj.stack) {
78
81
  // Here we're using the previously-generated "title line" (e.g "Error: some_message"),
79
82
  // concatenating it with the Stack (but without the title line of the Stack)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.167.0",
3
+ "version": "14.168.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -59,15 +59,6 @@ export interface ErrorData {
59
59
  */
60
60
  fingerprint?: string | string[]
61
61
 
62
- /**
63
- * If set to true - it'll use error.message as fingerprint,
64
- * so, all errors with the same message will be grouped together, even if they occurred in different places.
65
- * Defaults to false.
66
- *
67
- * @experimental
68
- */
69
- fingerprintByMessage?: boolean
70
-
71
62
  /**
72
63
  * Set when throwing an error from your backend code, to indicate desired http status code.
73
64
  * e.g throw new AppError('oj', { backendResponseStatusCode: 401 })
@@ -1,4 +1,4 @@
1
- import { _isBackendErrorResponseObject, _isErrorLike } from '../error/error.util'
1
+ import { _isBackendErrorResponseObject, _isErrorLike, _isErrorObject } from '../error/error.util'
2
2
  import type { Reviver } from '../types'
3
3
  import { _jsonParseIfPossible } from './json.util'
4
4
  import { _safeJsonStringify } from './safeJsonStringify'
@@ -47,6 +47,13 @@ export interface StringifyAnyOptions {
47
47
  */
48
48
  includeErrorCause?: boolean
49
49
 
50
+ /**
51
+ * Set to true to include Error.data.
52
+ *
53
+ * @default false
54
+ */
55
+ includeErrorData?: boolean
56
+
50
57
  /**
51
58
  * Allows to pass custom "stringify function".
52
59
  * E.g in Node.js you can pass `util.inspect` instead.
@@ -115,6 +122,10 @@ export function _stringifyAny(obj: any, opt: StringifyAnyOptions = {}): string {
115
122
  s += `\ncode: ${(obj as any).code}`
116
123
  }
117
124
 
125
+ if (opt.includeErrorData && _isErrorObject(obj)) {
126
+ s += '\n' + _stringifyAny(obj.data, opt)
127
+ }
128
+
118
129
  if (opt.includeErrorStack && obj.stack) {
119
130
  // Here we're using the previously-generated "title line" (e.g "Error: some_message"),
120
131
  // concatenating it with the Stack (but without the title line of the Stack)