micro-sentry icon indicating copy to clipboard operation
micro-sentry copied to clipboard

[BUG] Error thrown from an RxJS observable doesn't have any error message on Sentry

Open hakimio opened this issue 3 years ago • 0 comments

🐞 Bug report

Description

For some reason when error is thrown from Angular http client request observable, error message is not shown on Sentry. It just says "No error message". This worked as expected with official Angular Sentry client.

Reproduction

I have code similar to the following for processing http error responses.

@Injectable()
export class ReportService implements IReportService {

    constructor(private http: HttpClient) { }

    public getReport(reportConfig: ReportConfig): Observable<Report> {
        return this.http.get<{items: Report}>(`${environment.webApi}/adwords_report`, {
            params: reportConfig
        }).pipe(
            map(data => data.items),
            catchError((errorResponse: HttpErrorResponse) => {
                const error = errorResponse.error?.message || 'Server error',
                    status = errorResponse.status,
                    message = `Http error (${status}): ${error}`;

                return throwError(message);
            })
        );
    }
}

Expected behavior

Error message thrown from the observable should be sent to Sentry.

Versions

If needed:

  • OS: Ubuntu
  • Browser Chrome
  • Angular 12

hakimio avatar Jun 17 '21 08:06 hakimio