2.2.0 โ€ข Published 9 months ago

@exodus/errors v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@exodus/errors

Usage

import { sanitizeErrorMessage, parseStackTrace } from '@exodus/errors'

try {
  // the devil's work
} catch (e) {
  console.error(sanitizeErrorMessage(e.message))
  sendToErrorTrackingServer(parseStackTrace(e))
}

Troubleshooting

parseStackTrace returns undefined stack trace?

That likely means that something accesses error.stack before the parseStackTrace had a chance to apply the custom handler. This could be React, a high-level error handler, or any other framework. error.stack is computed only on the first access, so the custom handler (prepareStackTrace) wonโ€™t be called on subsequent attempts (see the stack.test.js for a quick demo).

If you can identify the exact place where .stack is accessed, consider capturing the stack trace explicitly like this:

import { parseStackTrace, captureStackTrace } from '@exodus/errors'

try {
  // the devil's work
} catch (e) {
  captureStackTrace(e)
  void e.stack // Intentionally access the property to "break" it here.
  sendToErrorTrackingServer(parseStackTrace(e))
  // ๐ŸŽ‰ Congrats โ€” you just (hopefully) saved hours of debugging! `parseStackTrace` now works because the stack was captured explicitly above.
}
2.2.0

9 months ago

3.0.0

9 months ago

2.1.1

9 months ago

2.1.0

9 months ago

2.0.2

11 months ago

2.0.1

11 months ago

2.0.0

11 months ago

1.3.0

12 months ago

1.2.0

12 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago