Sentry-javascript: Reference to a non-exported class RavenErrorHandler

Created on 8 Jan 2017  路  2Comments  路  Source: getsentry/sentry-javascript

Do you want to request a feature or report a bug?

report an encountered bug.

What is the current behavior?

In an Angular CLI project, I am trying to initialize raven on sentry.

app.module.ts

import * as Raven from 'raven-js';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { AppComponent } from './app.component';

Raven
    .config('https://[email protected]/127486')
    .install();

class RavenErrorHandler implements ErrorHandler {
    handleError(err:any) : void {
        Raven.captureException(err.originalError);
    }
}

@NgModule({
    imports: [ BrowserModule ],
    declarations: [ AppComponent ],
    bootstrap: [ AppComponent ],
    providers: [ { provide: ErrorHandler, useClass: RavenErrorHandler } ]
})
export class AppModule { }

Throws the exception

ERROR in Error encountered resolving symbol values statically. Reference to a non-exported class RavenErrorHandler. Consider exporting the class (position 10:1 in the original .ts file), resolving symbol AppModule in /home/**/projects/**/src/app/app.module.ts

What is the expected behavior?
browser: Chrome
angular-cli: 1.0.0-beta.24
node: 6.9.0
os: linux x64
angular: 2.3.1
ravenjs : "raven-js": "^3.9.1",

Most helpful comment

I was having the same issue.

Exporting solved it.

From:
class RavenErrorHandler implements ErrorHandler { handleError(err:any) : void { Raven.captureException(err.originalError); } }

To:
export class RavenErrorHandler implements ErrorHandler { handleError(err:any) : void { Raven.captureException(err.originalError); } }

All 2 comments

I think you need to export RavenErrorHandler for aot / ngc.

This should solve your error. But using Raven-JS with Angular CLI is still blocked by https://github.com/getsentry/raven-js/issues/822

I was having the same issue.

Exporting solved it.

From:
class RavenErrorHandler implements ErrorHandler { handleError(err:any) : void { Raven.captureException(err.originalError); } }

To:
export class RavenErrorHandler implements ErrorHandler { handleError(err:any) : void { Raven.captureException(err.originalError); } }

Was this page helpful?
0 / 5 - 0 ratings