@chubbyts/chubbyts-throwable-to-error 2.3.2 → 2.3.3

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/README.md CHANGED
@@ -30,7 +30,7 @@ It converts any throwable into an Error.
30
30
  Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-throwable-to-error][1].
31
31
 
32
32
  ```ts
33
- npm i @chubbyts/chubbyts-throwable-to-error@^2.3.2
33
+ npm i @chubbyts/chubbyts-throwable-to-error@^2.3.3
34
34
  ```
35
35
 
36
36
  ## Usage
@@ -4,8 +4,10 @@ const throwableToMessage = (e) => {
4
4
  try {
5
5
  // JSON.stringify / String may invoke user-defined toJSON/toString/getters, which can throw,
6
6
  // and JSON.stringify throws on circular references and returns undefined for some inputs.
7
- const message = typeof e === 'object' ? JSON.stringify(e) : String(e);
8
- return message ?? '[unserializable]';
7
+ if (typeof e === 'object') {
8
+ return JSON.stringify(e) ?? '[unserializable]';
9
+ }
10
+ return String(e);
9
11
  }
10
12
  catch {
11
13
  return '[unserializable]';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chubbyts/chubbyts-throwable-to-error",
3
3
  "type": "module",
4
- "version": "2.3.2",
4
+ "version": "2.3.3",
5
5
  "description": "It converts any throwable into an Error.",
6
6
  "keywords": [
7
7
  "chubbyts",