Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reportError(err) {
// Log the error
logger.error(err);
// Log the error on Sentry
Sentry.captureException(err);
}
// 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)
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);
}
_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}`);
}
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 });
}
}
};
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)
}
}
process.on('unhandledRejection', e => {
Sentry.captureException(e);
});
process.on('uncaughtException', e => {
.catch((err: any) => {
sentry.captureException(err);
Task.setResult(Task.TaskResult.Failed, `Task Failed. Error: ${JSON.stringify(err)}`);
});
formatError: (e) => {
Sentry.captureException(e);
return formatError(e);
},
tracing: getSetting('apolloTracing', Meteor.isDevelopment),
} 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.');
}
}