Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Sentry.captureException not working in an Angular app #29

Open
tangerinegit opened this issue Apr 24, 2019 · 1 comment
Open

Sentry.captureException not working in an Angular app #29

tangerinegit opened this issue Apr 24, 2019 · 1 comment

Comments

@tangerinegit
Copy link

Here is my code:

app.module.ts:

import { SentryModule } from 'nativescript-sentry/angular';

@NgModule({
    bootstrap: [
        AppComponent
    ],
    imports: [
        SentryModule.forRoot({ dsn: 'https://<code>:<code>@sentry.io/<project_id>' })
    ],
})
export class AppModule {}

GlobalErrorHandler.ts

import { ErrorHandler, Injectable } from '@angular/core';
import { Sentry } from 'nativescript-sentry';

@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
    constructor() { }
    handleError(error) {
        Sentry.captureException(error, { });
        throw error;
    }
}

When I throw a test error, the app crashes, the code in the global error handler executes, but when I log in to our dashboard in Sentry.io, I do not see any events logged.

Am I missing anything in the setup?

Thanks.

@LABCAT
Copy link

LABCAT commented Feb 26, 2020

I having the same issue but have found it works if I use the captureMessage function instead.

Using the examples doesn't work:
try { throw 'try catch Exception example'; } catch (error) { Sentry.captureException(error, {}); }

Is that because 'error' is a string and not an exception?

Sentry.captureException(exeption: Error, options?: ExceptionOptions);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants