From f041623403ce4074bde8ec00f6a6a0086c6c45e8 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 1 Nov 2018 23:44:49 +0100 Subject: [PATCH] fix(errors): now handles uncaught errors --- ts/sentry.classes.sentry.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ts/sentry.classes.sentry.ts b/ts/sentry.classes.sentry.ts index 99b5f79..ab1575d 100644 --- a/ts/sentry.classes.sentry.ts +++ b/ts/sentry.classes.sentry.ts @@ -17,6 +17,15 @@ export class Sentry { plugins.sentry.init({ dsn: optionsArg.dsn }); + process + .on('unhandledRejection', (reason, p) => { + console.error(reason, 'Unhandled Rejection at Promise', p); + }) + .on('uncaughtException', err => { + console.log(err); + this.captureException(err); + process.exit(1); + }); } captureException(exceptionArg: any) {