Sentry-javascript: Can NOT capture error wrapped rxjs.Observable.error()

Created on 2 Apr 2020  路  1Comment  路  Source: getsentry/sentry-javascript

Package + Version

  • [x] @sentry/browser
  • [ ] @sentry/node
  • [ ] raven-js
  • [ ] raven-node _(raven for node)_
  • [ ] other:

Version:

5.15.4

Description

My application(Angular@9) throws rxjs.Observable.error() and catch that by Sentry.captureException();.
At Sentry.io, I saw

Hub.push../node_modules/@sentry/hub/esm/hub.js.Hub.withScope
error
Non-Error exception captured with keys: ...

https://sentry.io/organizations/{myorg}/issues/1582573825/

It may be better that Sentry.captureException() could be to catch rxjs.Observable.error() simply.
Or had I mistaken for using @sentry/browser ??

code

import { Component } from "@angular/core";
import { Observable } from "rxjs";

@Component({
  selector: "app-root",
  template: `<button (click)="myProcess()"></button>`
})
export class AppComponent {
  public myProcess(): void {
    new Observable<{message: string}>(observer => {
      observer.error({message: "my failure..."});
    }).subscribe(result => console.log(result));
  }
}

@Injectable()
export class SentryErrorHandler implements ErrorHandler {
  constructor() {}
  handleError(error) {
    Sentry.captureException(error.originalError || error);
  }
}
Needs Triage

Most helpful comment

I also hit this error but the OP wasn't super clear to me so I've created a repro: https://github.com/goosmurf/sentry-javascript-2533

You'll need to replace the DSN, then ng serve and visit https://localhost:4200/

Note that the handleError() is basically a no-op but an exception is still logged.

If you set a breakpoint against Sentry.captureException() you can further observe that the exception is logged to sentry.io prior to handleError() being called.

>All comments

I also hit this error but the OP wasn't super clear to me so I've created a repro: https://github.com/goosmurf/sentry-javascript-2533

You'll need to replace the DSN, then ng serve and visit https://localhost:4200/

Note that the handleError() is basically a no-op but an exception is still logged.

If you set a breakpoint against Sentry.captureException() you can further observe that the exception is logged to sentry.io prior to handleError() being called.

Was this page helpful?
0 / 5 - 0 ratings