How to use the @bugsnag/core/lib/node-fallback-stack.getStack 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-intercept / intercept.js View on Github external
const intercept = (opts, cb = () => {}) => {
      if (typeof opts === 'function') {
        cb = opts
        opts = {}
      }

      // capture a stacktrace in case a resulting error has nothing
      const fallbackStack = getStack()

      return (err, ...data) => {
        if (err) {
          // check if the stacktrace has no context, if so, if so append the frames we created earlier
          if (err.stack) maybeUseFallbackStack(err, fallbackStack)
          const report = createReportFromErr(err, {
            severity: 'warning',
            unhandled: false,
            severityReason: { type: 'callbackErrorIntercept' }
          })
          client.notify(report, opts)
          return
        }
        cb(...data) // eslint-disable-line
      }
    }
github bugsnag / bugsnag-js / packages / plugin-contextualize / contextualize.js View on Github external
const contextualize = (fn, opts) => {
      // capture a stacktrace in case a resulting error has nothing
      const fallbackStack = getStack()

      const dom = domain.create()
      dom.on('error', err => {
        // check if the stacktrace has no context, if so, if so append the frames we created earlier
        if (err.stack) maybeUseFallbackStack(err, fallbackStack)
        const report = createReportFromErr(err, {
          severity: 'error',
          unhandled: true,
          severityReason: { type: 'unhandledException' }
        })
        client.notify(report, opts, (e, report) => {
          if (e) client._logger.error('Failed to send report to Bugsnag')
          client.config.onUncaughtException(err, report, client._logger)
        })
      })
      process.nextTick(() => dom.run(fn))