@exodus/errors 1.0.1 → 1.1.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
+ ## [1.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/errors@1.0.1...@exodus/errors@1.1.0) (2024-08-19)
7
+
8
+ ### Features
9
+
10
+ - add parseStackTrace ([#8160](https://github.com/ExodusMovement/exodus-hydra/issues/8160)) ([def6590](https://github.com/ExodusMovement/exodus-hydra/commit/def659012e87d75147d40e8c3dde0f2f7ec4f731))
11
+
6
12
  ## [1.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/errors@1.0.0...@exodus/errors@1.0.1) (2024-07-30)
7
13
 
8
14
  ### Bug Fixes
package/README.md CHANGED
@@ -3,11 +3,12 @@
3
3
  ## Usage
4
4
 
5
5
  ```javascript
6
- import sanitizeErrorMessage from '@exodus/errors/sanitize'
6
+ import { sanitizeErrorMessage, parseStackTrace } from '@exodus/errors'
7
7
 
8
8
  try {
9
9
  // the devil's work
10
10
  } catch (e) {
11
11
  console.error(sanitizeErrorMessage(e.message))
12
+ sendToErrorTrackingServer(parseStackTrace(e))
12
13
  }
13
14
  ```
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { default as sanitizeErrorMessage } from './sanitize.js';
2
+ export { default as parseStackTrace } from './stack.js';
package/lib/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { default as sanitizeErrorMessage } from './sanitize.js';
2
+ export { default as parseStackTrace } from './stack.js';
package/lib/stack.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { Frame } from './types.js';
2
+ export default function parseStackTraceNatively(err: Error): Frame[] | undefined;
package/lib/stack.js ADDED
@@ -0,0 +1,28 @@
1
+ export default function parseStackTraceNatively(err) {
2
+ const { prepareStackTrace } = Error;
3
+ let stack;
4
+ let calledOn;
5
+ Error.prepareStackTrace = (e, callSites) => {
6
+ calledOn = e;
7
+ stack = callSites.map((trace) => ({
8
+ function: trace.getFunctionName(),
9
+ method: trace.getMethodName(),
10
+ file: trace.getFileName(),
11
+ line: trace.getLineNumber(),
12
+ column: trace.getColumnNumber(),
13
+ // see https://v8.dev/docs/stack-trace-api
14
+ async: trace.isAsync?.(),
15
+ toplevel: trace.isToplevel(),
16
+ }));
17
+ };
18
+ try {
19
+ // eslint-disable-next-line no-unused-expressions
20
+ err.stack; // trigger prepareStackTrace
21
+ }
22
+ finally {
23
+ Error.prepareStackTrace = prepareStackTrace;
24
+ }
25
+ // @ts-expect-error calledOn gets assigned in prepareStackTrace
26
+ if (calledOn === err && Array.isArray(stack))
27
+ return stack;
28
+ }
package/lib/types.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export type Frame = {
2
+ function?: string;
3
+ method?: string;
4
+ file?: string;
5
+ line?: number;
6
+ column?: number;
7
+ async?: boolean;
8
+ toplevel?: boolean;
9
+ in_app?: boolean;
10
+ };
package/lib/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exodus/errors",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "description": "Utilities for error handling in client code, such as sanitization",
6
6
  "author": "Exodus Movement, Inc.",
7
7
  "repository": {
@@ -29,10 +29,13 @@
29
29
  "clean": "run -T tsc --build --clean",
30
30
  "lint": "run -T eslint . --ignore-path ../../.gitignore",
31
31
  "lint:fix": "yarn lint --fix",
32
- "test": "run -T exodus-test --esbuild"
32
+ "test": "yarn run test:v8 && yarn run test:hermes",
33
+ "test:v8": "run -T exodus-test --esbuild --jest src/__tests__/v8/*.test.ts",
34
+ "test:hermes": "run -T exodus-test --engine hermes:bundle --esbuild --jest src/__tests__/hermes/*.test.ts"
33
35
  },
34
36
  "devDependencies": {
35
- "@exodus/errors-fixture": "^1.0.0"
37
+ "@exodus/errors-fixture": "^1.0.0",
38
+ "hermes-engine-cli": "^0.12.0"
36
39
  },
37
- "gitHead": "0d8159f0439781615acfe284ce978b35ae228fb5"
40
+ "gitHead": "0f5db1a33a6a8dd5fee393f6d8204504af5c2c6e"
38
41
  }