code: function (error) {
                  var res = new HttpErrorResponse({
                      error: error,
                      status: xhr.status || 0,
                      statusText: xhr.statusText || 'Unknown Error',
                  });
                  observer.error(res);
              }
docs: The onError callback is called when something goes wrong at the network level. Connection timeout, DNS error, offline, etc. These are actual errors, and are transmitted on the error channel.