@exodus/errors 3.2.0 → 3.4.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,18 @@
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.4.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/errors@3.3.0...@exodus/errors@3.4.0) (2025-10-14)
7
+
8
+ ### Features
9
+
10
+ - feat: support capturing error context (#13933)
11
+
12
+ ## [3.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/errors@3.2.0...@exodus/errors@3.3.0) (2025-08-08)
13
+
14
+ ### Features
15
+
16
+ - feat(errors): add network error patterns to common errors (#13516)
17
+
6
18
  ## [3.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/errors@3.1.0...@exodus/errors@3.2.0) (2025-08-07)
7
19
 
8
20
  ### Features
@@ -43,6 +43,18 @@ declare const commonErrors: readonly [{
43
43
  }, {
44
44
  readonly pattern: RegExp;
45
45
  readonly normalized: "JSON Parse error";
46
+ }, {
47
+ readonly pattern: RegExp;
48
+ readonly normalized: "Network request failed";
49
+ }, {
50
+ readonly pattern: RegExp;
51
+ readonly normalized: "Network error";
52
+ }, {
53
+ readonly pattern: RegExp;
54
+ readonly normalized: "Connection failed";
55
+ }, {
56
+ readonly pattern: RegExp;
57
+ readonly normalized: "Request failed";
46
58
  }];
47
59
  export type CommonErrorString = (typeof commonErrors)[number]['normalized'];
48
60
  export declare function toCommonErrorMessage(errorMessage: string): CommonErrorString | undefined;
@@ -59,6 +59,22 @@ const commonErrors = [
59
59
  pattern: /^JSON Parse error:/iu,
60
60
  normalized: 'JSON Parse error',
61
61
  },
62
+ {
63
+ pattern: /network request failed/iu,
64
+ normalized: 'Network request failed',
65
+ },
66
+ {
67
+ pattern: /network error/iu,
68
+ normalized: 'Network error',
69
+ },
70
+ {
71
+ pattern: /connection failed/iu,
72
+ normalized: 'Connection failed',
73
+ },
74
+ {
75
+ pattern: /request failed/iu,
76
+ normalized: 'Request failed',
77
+ },
62
78
  ];
63
79
  export function toCommonErrorMessage(errorMessage) {
64
80
  if (!errorMessage)
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as sanitizeErrorMessage } from './sanitize.js';
2
2
  export { default as parseStackTrace, captureStackTrace } from './stack.js';
3
3
  export * from './safe-error.js';
4
+ export { SafeContext, type SafeContextType } from './safe-context/index.js';
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as sanitizeErrorMessage } from './sanitize.js';
2
2
  export { default as parseStackTrace, captureStackTrace } from './stack.js';
3
3
  export * from './safe-error.js';
4
+ export { SafeContext } from './safe-context/index.js';
@@ -0,0 +1,5 @@
1
+ import { type SafeContextType } from './schemas.js';
2
+ export declare const SafeContext: {
3
+ parse(unsafeContext: unknown): SafeContextType;
4
+ };
5
+ export type { SafeContextType } from './schemas.js';
@@ -0,0 +1,11 @@
1
+ import { getContextSchema } from './schemas.js';
2
+ export const SafeContext = {
3
+ parse(unsafeContext) {
4
+ try {
5
+ return getContextSchema().parse(unsafeContext);
6
+ }
7
+ catch {
8
+ return undefined;
9
+ }
10
+ },
11
+ };
@@ -0,0 +1,26 @@
1
+ import { z } from '@exodus/zod';
2
+ declare const createContextSchema: () => z.ZodOptional<z.ZodNullable<z.ZodObject<{
3
+ navigation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
4
+ currentRouteName: z.ZodEffects<z.ZodString, string, string>;
5
+ previousRouteName: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
6
+ }, "strict", z.ZodTypeAny, {
7
+ currentRouteName: string;
8
+ previousRouteName?: string | null | undefined;
9
+ }, {
10
+ currentRouteName: string;
11
+ previousRouteName?: string | null | undefined;
12
+ }>>>;
13
+ }, "strict", z.ZodTypeAny, {
14
+ navigation?: {
15
+ currentRouteName: string;
16
+ previousRouteName?: string | null | undefined;
17
+ } | null | undefined;
18
+ }, {
19
+ navigation?: {
20
+ currentRouteName: string;
21
+ previousRouteName?: string | null | undefined;
22
+ } | null | undefined;
23
+ }>>>;
24
+ declare const getContextSchema: any;
25
+ export type SafeContextType = z.infer<ReturnType<typeof createContextSchema>>;
26
+ export { getContextSchema };
@@ -0,0 +1,18 @@
1
+ import { z } from '@exodus/zod';
2
+ import { isSafe } from '@exodus/safe-string';
3
+ import { memoize } from '@exodus/basic-utils';
4
+ const createContextSchema = () => z
5
+ .object({
6
+ navigation: z
7
+ .object({
8
+ currentRouteName: z.string().refine(isSafe),
9
+ previousRouteName: z.string().refine(isSafe).nullish(),
10
+ })
11
+ .strict()
12
+ .nullish(),
13
+ })
14
+ .strict()
15
+ .nullish();
16
+ // Memoize the factory for lazy loading.
17
+ const getContextSchema = memoize(createContextSchema);
18
+ export { getContextSchema };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exodus/errors",
3
3
  "type": "module",
4
- "version": "3.2.0",
4
+ "version": "3.4.0",
5
5
  "description": "Utilities for error handling in client code, such as sanitization",
6
6
  "author": "Exodus Movement, Inc.",
7
7
  "repository": {
@@ -34,7 +34,9 @@
34
34
  "test:hermes": "EXODUS_TEST_COVERAGE=0 run -T exodus-test --engine hermes:bundle --esbuild --jest src/__tests__/hermes/*.test.ts src/__tests__/engine-agnostic/*.test.ts"
35
35
  },
36
36
  "dependencies": {
37
+ "@exodus/basic-utils": "^3.0.1",
37
38
  "@exodus/safe-string": "^1.2.0",
39
+ "@exodus/zod": "^3.24.2",
38
40
  "minimalistic-assert": "^1.0.1"
39
41
  },
40
42
  "devDependencies": {
@@ -42,7 +44,8 @@
42
44
  "@types/minimalistic-assert": "^1.0.1"
43
45
  },
44
46
  "publishConfig": {
45
- "access": "public"
47
+ "access": "public",
48
+ "provenance": false
46
49
  },
47
- "gitHead": "b229da233485c8301fa03c8b189a55f866eb4fe0"
50
+ "gitHead": "1c7823e1ee4d02280aff05d67169e915ed7909ca"
48
51
  }