NG.VII · Angular 22 practice question
An HttpClient request fails because the backend returns a 500 error. How does HttpClient surface this failure to subscribers?
Check answer and explanation
Correct answer: It emits an HttpErrorResponse through the Observable error channel.
Explanation
HttpClient wraps network, timeout, and backend failures in an HttpErrorResponse and delivers it through the Observable error channel.
Common trap
HttpClient does not swallow HTTP errors into null values; subscribers must handle failures via the error callback or catchError. HttpClient methods return Observables rather than Promises, and they wrap failures in HttpErrorResponse.
Source: Angular docs: Making HTTP requests — Handling request failure
Checked against the cited text on 2026-11-25.