How to use the @bugsnag/core/lib/error-stack-parser.parse function in @bugsnag/core

To help you get started, we’ve selected a few @bugsnag/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-js / packages / plugin-window-unhandled-rejection / unhandled-rejection.js View on Github external
if (event.detail && event.detail.reason) {
        error = event.detail.reason
        isBluebird = true
      }
    } catch (e) {}

    const handledState = {
      severity: 'error',
      unhandled: true,
      severityReason: { type: 'unhandledPromiseRejection' }
    }

    let report
    if (error && hasStack(error)) {
      // if it quacks like an Error…
      report = new client.BugsnagReport(error.name, error.message, ErrorStackParser.parse(error), handledState, error)
      if (isBluebird) {
        report.stacktrace = reduce(report.stacktrace, fixBluebirdStacktrace(error), [])
      }
    } else {
      // if it doesn't…
      const msg = 'Rejection reason was not an Error. See "Promise" tab for more detail.'
      report = new client.BugsnagReport(
        error && error.name ? error.name : 'UnhandledRejection',
        error && error.message ? error.message : msg,
        [],
        handledState,
        error
      )
      // stuff the rejection reason into metaData, it could be useful
      report.updateMetaData('promise', 'rejection reason', serializableReason(error))
    }