diff --git a/packages/common/http/src/xhr.ts b/packages/common/http/src/xhr.ts index c0a388dc94..9dc01058b6 100644 --- a/packages/common/http/src/xhr.ts +++ b/packages/common/http/src/xhr.ts @@ -232,10 +232,12 @@ export class HttpXhrBackend implements HttpBackend { // Connection timeout, DNS error, offline, etc. These are actual errors, and are // transmitted on the error channel. const onError = (error: ErrorEvent) => { + const {url} = partialFromXhr(); const res = new HttpErrorResponse({ error, status: xhr.status || 0, statusText: xhr.statusText || 'Unknown Error', + url: url || undefined, }); observer.error(res); }; diff --git a/packages/common/http/test/xhr_spec.ts b/packages/common/http/test/xhr_spec.ts index dfafef1df3..88e608d484 100644 --- a/packages/common/http/test/xhr_spec.ts +++ b/packages/common/http/test/xhr_spec.ts @@ -142,6 +142,7 @@ const XSSI_PREFIX = ')]}\'\n'; backend.handle(TEST_POST).subscribe(undefined, (err: HttpErrorResponse) => { expect(err instanceof HttpErrorResponse).toBe(true); expect(err.error instanceof Error); + expect(err.url).toBe('/test'); done(); }); factory.mock.mockErrorEvent(new Error('blah'));