@exodus/errors 3.1.0 → 3.2.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/errors@3.1.0...@exodus/errors@3.2.0) (2025-08-07)
7
+
8
+ ### Features
9
+
10
+ - feat: add more specific JSON parse error handling (#13295)
11
+
6
12
  ## [3.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/errors@3.0.1...@exodus/errors@3.1.0) (2025-08-04)
7
13
 
8
14
  ### Features
@@ -28,12 +28,21 @@ declare const commonErrors: readonly [{
28
28
  }, {
29
29
  readonly pattern: RegExp;
30
30
  readonly normalized: "Cannot access property of null";
31
+ }, {
32
+ readonly pattern: RegExp;
33
+ readonly normalized: "JSON Parse error: Unexpected token";
34
+ }, {
35
+ readonly pattern: RegExp;
36
+ readonly normalized: "JSON Parse error: Unexpected token";
31
37
  }, {
32
38
  readonly pattern: RegExp;
33
39
  readonly normalized: "Unexpected token";
34
40
  }, {
35
41
  readonly pattern: RegExp;
36
- readonly normalized: "Unexpected end of input";
42
+ readonly normalized: "JSON Parse error: Unexpected end of input";
43
+ }, {
44
+ readonly pattern: RegExp;
45
+ readonly normalized: "JSON Parse error";
37
46
  }];
38
47
  export type CommonErrorString = (typeof commonErrors)[number]['normalized'];
39
48
  export declare function toCommonErrorMessage(errorMessage: string): CommonErrorString | undefined;
@@ -39,13 +39,25 @@ const commonErrors = [
39
39
  pattern: /null is not an object \(evaluating '.*'\)/iu,
40
40
  normalized: 'Cannot access property of null',
41
41
  },
42
+ {
43
+ pattern: /JSON Parse error: Unexpected (token|character)/iu,
44
+ normalized: 'JSON Parse error: Unexpected token',
45
+ },
46
+ {
47
+ pattern: /Unexpected token.*is not valid JSON/iu,
48
+ normalized: 'JSON Parse error: Unexpected token',
49
+ },
42
50
  {
43
51
  pattern: /unexpected (token|character)/iu,
44
52
  normalized: 'Unexpected token',
45
53
  },
46
54
  {
47
55
  pattern: /unexpected end of( JSON)? input/iu,
48
- normalized: 'Unexpected end of input',
56
+ normalized: 'JSON Parse error: Unexpected end of input',
57
+ },
58
+ {
59
+ pattern: /^JSON Parse error:/iu,
60
+ normalized: 'JSON Parse error',
49
61
  },
50
62
  ];
51
63
  export function toCommonErrorMessage(errorMessage) {
@@ -1,7 +1,7 @@
1
1
  import type { Frame } from './types.js';
2
2
  import type { CommonErrorString } from './common-errors.js';
3
3
  type ReadonlySetValues<S> = S extends ReadonlySet<infer T> ? T : never;
4
- declare const SAFE_NAMES_SET: ReadonlySet<"Error" | "AssertionError" | "TypeError" | "RangeError" | "UnknownError" | "SafeErrorFailedToParse" | "TimeoutError">;
4
+ declare const SAFE_NAMES_SET: ReadonlySet<"Error" | "AssertionError" | "TypeError" | "RangeError" | "UnknownError" | "SafeErrorFailedToParse" | "TimeoutError" | "SyntaxError">;
5
5
  type StaticAllowlistString = string & {
6
6
  __branded_type: 'StaticAllowlistString';
7
7
  };
@@ -21,7 +21,7 @@ declare const FACTORY_SYMBOL: unique symbol;
21
21
  export declare class SafeError {
22
22
  #private;
23
23
  static from<T extends UnknownError>(err: T): SafeError;
24
- get name(): "Error" | "AssertionError" | "TypeError" | "RangeError" | "UnknownError" | "SafeErrorFailedToParse" | "TimeoutError";
24
+ get name(): "Error" | "AssertionError" | "TypeError" | "RangeError" | "UnknownError" | "SafeErrorFailedToParse" | "TimeoutError" | "SyntaxError";
25
25
  get code(): SafeCode | undefined;
26
26
  get hint(): SafeString | undefined;
27
27
  get stackFrames(): {
package/lib/safe-error.js CHANGED
@@ -15,6 +15,7 @@ const SAFE_NAMES_SET = makeReadonlySet([
15
15
  'UnknownError',
16
16
  'SafeErrorFailedToParse',
17
17
  'TimeoutError',
18
+ 'SyntaxError',
18
19
  ]);
19
20
  function isSafeName(value) {
20
21
  return SAFE_NAMES_SET.has(value);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exodus/errors",
3
3
  "type": "module",
4
- "version": "3.1.0",
4
+ "version": "3.2.0",
5
5
  "description": "Utilities for error handling in client code, such as sanitization",
6
6
  "author": "Exodus Movement, Inc.",
7
7
  "repository": {
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "917eaccefaf98df19b72a145a52510759cea1237"
47
+ "gitHead": "b229da233485c8301fa03c8b189a55f866eb4fe0"
48
48
  }