Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong error type in httpclient doc #34748

Open
wildsalarian opened this issue Jan 12, 2020 · 0 comments
Open

Wrong error type in httpclient doc #34748

wildsalarian opened this issue Jan 12, 2020 · 0 comments

Comments

@wildsalarian
Copy link

@wildsalarian wildsalarian commented Jan 12, 2020

馃摎 Docs or angular.io bug report

Description

A type was changed in a recent commit in angular which is not yet represented in the docs.

What's the affected URL?**

https://angular.io/guide/http#getting-error-details

Reproduction Steps**

In the code snippet app/config/config.service.ts there is this line:

if (error.error instanceof ErrorEvent)

In case of a network error (or similar like a CORS error) the error property of the HttpErrorResponse is should be according to the docs an ErrorEvent. But in my tests always seems to be a ProgressEvent.

In this recent commit
0139b11#diff-26683cfb34fa97883213282055aef1e7
in the file
packages/common/http/src/xhr.ts
the type of the error property of the returned HttpErrorResponse was changed from ErrorEvent to ProgressEvent.

Unfortunately unlike ErrorEvent the ProgressEvent has no message property. It is only usable as a indicator for a network error. The message property of the HttpErrorResponse itself has to be queried to retrieve a human readable error message.

The behaviour can be tested in
https://stackblitz.com/edit/error-handling-httpclient?file=src%2Fapp%2Fuser.service.ts

I am using Angular 8.2.14

@ngbot ngbot bot added this to the needsTriage milestone Jan 13, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jan 13, 2020
@kapunahelewong kapunahelewong added this to Need Assistance from Eng. in docs Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
docs
Need Assistance from Eng.
3 participants
You can鈥檛 perform that action at this time.