Tinkoff / micro-sentry

Tiny Sentry client with idiomatic wrapper for Angular
Apache License 2.0
118 stars 8 forks source link

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

Open hakimio opened 3 years ago

hakimio commented 3 years ago

🐞 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: