Skip to content

Can NOT capture error wrapped rxjs.Observable.error() #2533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 9 tasks
sizer opened this issue Apr 2, 2020 · 5 comments
Closed
5 of 9 tasks

Can NOT capture error wrapped rxjs.Observable.error() #2533

sizer opened this issue Apr 2, 2020 · 5 comments

Comments

@sizer
Copy link

sizer commented Apr 2, 2020

Package + Version

  • @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);
  }
}
@goosmurf
Copy link

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.

@pranav-js
Copy link

pranav-js commented May 6, 2021

I use

import { throwError } from 'rxjs';

throwError(err);

Works fine, But these are captured 2 times in sentry

one with GlobalErrorHandlerService.handleError
other with Hub.push.lW6c.Hub.withScope

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@pomali
Copy link

pomali commented Jan 31, 2024

for those wondering - I solved similar problem using error property in Observer - like this

observable.pipe(...).subscribe({
  next: result => console.log(result),
  error: err => { /* handle or ignore error */}
})

this way default angular/rxjs error handler doesn't raise the exception

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

No branches or pull requests

7 participants