topkat-utils 1.2.71 → 1.2.72

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topkat-utils",
3
- "version": "1.2.71",
3
+ "version": "1.2.72",
4
4
  "type": "commonjs",
5
5
  "types": "index.ts",
6
6
  "main": "dist",
@@ -8,6 +8,7 @@ import { ErrorOptions } from './types'
8
8
  import { cleanStackTrace } from './clean-stack-trace'
9
9
  import { C } from './logger-utils'
10
10
  export { type ErrorOptions } from './types'
11
+ import { removeCircularJSONstringify } from './remove-circular-json-stringify'
11
12
 
12
13
  export function errIfNotSet(objOfVarNamesWithValues) { return errXXXIfNotSet(422, false, objOfVarNamesWithValues) }
13
14
 
@@ -48,10 +49,12 @@ export const failSafe = tryCatch // ALIAS
48
49
  function extraInfosRendererDefault(extraInfos) {
49
50
  return [
50
51
  '== EXTRA INFOS ==',
51
- JSON.stringify(extraInfos, null, 2)
52
+ removeCircularJSONstringify(extraInfos, 2)
52
53
  ]
53
54
  }
54
55
 
56
+
57
+
55
58
  export class DescriptiveError extends Error {
56
59
  /** Full error infos, extra infos + message and code...etc as object */
57
60
  errorDescription: { [k: string]: any } = {}
@@ -81,8 +84,8 @@ export class DescriptiveError extends Error {
81
84
  if (!this.hasBeenLogged) this.log()
82
85
  })
83
86
 
84
- const { onError = () => { /** */ } } = configFn()
85
- onError(msg, options)
87
+ const { onError } = configFn()
88
+ if (typeof onError === 'function') onError(msg, options)
86
89
 
87
90
  }
88
91
  /** Compute extraInfos and parse options */