fix(common): expose request url in network error (#27143)
closes #27029 PR Close #27143
This commit is contained in:
parent
f45aedcbf0
commit
1db53da0d3
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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'));
|
||||
|
|
Loading…
Reference in New Issue