How to use the @sentry/node.captureException function in @sentry/node

To help you get started, we’ve selected a few @sentry/node 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 dice-discord / bot / src / dice.js View on Github external
reportError(err) {
    // Log the error
    logger.error(err);
    // Log the error on Sentry
    Sentry.captureException(err);
  }
github zeit / next.js / examples / with-sentry-simple / pages / _error.js View on Github external
// getInitialProps has run
  errorInitialProps.hasGetInitialPropsRun = true

  if (res) {
    // Running on the server, the response object is available.
    //
    // Next.js will pass an err on the server if a page's `getInitialProps`
    // threw or returned a Promise that rejected

    if (res.statusCode === 404) {
      // Opinionated: do not record an exception in Sentry for 404
      return { statusCode: 404 }
    }

    if (err) {
      Sentry.captureException(err)

      return errorInitialProps
    }
  } else {
    // Running on the client (browser).
    //
    // Next.js will provide an err if:
    //
    //  - a page's `getInitialProps` threw or returned a Promise that rejected
    //  - an exception was thrown somewhere in the React lifecycle (render,
    //    componentDidMount, etc) that was caught by Next.js's React Error
    //    Boundary. Read more about what types of exceptions are caught by Error
    //    Boundaries: https://reactjs.org/docs/error-boundaries.html
    if (err) {
      Sentry.captureException(err)
github nusmodifications / nusmods / export / app.js View on Github external
const errorHandler = async (ctx, next) => {
  try {
    await next();

    if (ctx.status === 404) {
      await ctx.render('404');
      ctx.status = 404;
    }
  } catch (e) {
    const eventId = Sentry.captureException(e.original || e);

    console.error(e);

    ctx.status = e.status || 500;

    if (ctx.status === 422) {
      await ctx.render('422');
    } else {
      await ctx.render('500', {
        eventId,
        dsn: config.publicDsn,
      });
    }

    ctx.app.emit('error', e, ctx);
  }
github metaspace2020 / metaspace / metaspace / graphql / src / modules / dataset / controller / Subscription.ts View on Github external
_source: {
              ...ds._source,
            }
          },
          action,
          stage,
          ...rest,
        });
        return;
      }

      await wait(50 * attempt * attempt);
    }
  } catch (err) {
    logger.error(err);
    Sentry.captureException(err);
  }

  logger.warn(`Failed to propagate dataset update for ${ds_id}`);
}
github mozilla / fxa / packages / fxa-event-broker / lib / serviceNotifications.ts View on Github external
from(logger: Logger, rawMessage: object): ServiceNotification | undefined {
    try {
      const validMessage = multiSchemaAttempt(eventSchemas, rawMessage);
      if (validMessage) {
        logger.debug('from.sqsMessage', { msg: validMessage });
        return validMessage;
      }
    } catch (err) {
      sentry.captureException(err);
      logger.error('from.sqsMessage', { message: 'Invalid message', err });
    }
  }
};
github telegram-ru / ru-bot / src / features / spam-hammer / keyboards.js View on Github external
const [, targetId] = match
  const hammer = getHammer()
  const { message } = update.callback_query

  debug('handleUnspamUserOk', targetId, { from, message })
  try {
    const originalMessage = reconstructMarkdown(message)

    editMessageText(
      `${originalMessage}\n${text.spamHammer.userUnspammed({ moder: from, spammer: { id: targetId } })}`,
      { parse_mode: 'Markdown' },
    )
    await hammer.whitelistUser({ id: targetId })
  }
  catch (error) {
    Sentry.captureException(error)
    debug('handleUnspamUserOk ERROR', error)
  }
}
github Lightmatter / generic-django-conf / {{cookiecutter.repo_name}} / src / pages / _document.jsx View on Github external
process.on('unhandledRejection', e => {
    Sentry.captureException(e);
});
process.on('uncaughtException', e => {
github kasunkv / owasp-zap-vsts-task / BuildTask / OwaspZapScan / owaspzapscan.ts View on Github external
.catch((err: any) => {
        sentry.captureException(err);
        Task.setResult(Task.TaskResult.Failed, `Task Failed. Error: ${JSON.stringify(err)}`);
    });
github LessWrong2 / Lesswrong2 / packages / vulcan-lib / lib / server / apollo-server / apollo_server.js View on Github external
formatError: (e) => {
        Sentry.captureException(e);
        return formatError(e);
      },
      tracing: getSetting('apolloTracing', Meteor.isDevelopment),
github keyteki / keyteki / server / gamenode / gameserver.js View on Github external
} else {
            debugData.game = gameState;
            debugData.game.players = undefined;

            debugData.messages = game.getPlainTextLog();
            debugData.game.messages = undefined;

            _.each(game.getPlayers(), player => {
                debugData[player.name] = player.getState(player);
            });
        }

        Sentry.configureScope((scope) => {
            scope.setExtra('extra', debugData);
        });
        Sentry.captureException(e);
        if(game) {
            game.addMessage('A Server error has occured processing your game state, apologies.  Your game may now be in an inconsistent state, or you may be able to continue.  The error has been logged.');
        }
    }