function buildThrowingStubXhr(err) {
  return {
    sent: false,
    aborted: false,
    status: 0,
    headers: {},
    open: function(method, url, async) {
      /** @suppress {globalThis} suppression added to enable type checking */
      this.method = method;
      /** @suppress {globalThis} suppression added to enable type checking */
      this.url = url;
      /** @suppress {globalThis} suppression added to enable type checking */
      this.async = async;
    },
    setRequestHeader: function(key, value) {
      /** @suppress {globalThis} suppression added to enable type checking */
      this.headers[key] = value;
    },
    overrideMimeType: function(mimeType) {
      /** @suppress {globalThis} suppression added to enable type checking */
      this.mimeType = mimeType;
    },
    send: function(data) {
      throw err;
    }
  };
}
@param {!Error} err Error to be thrown when sending this stub XHR.
@return {!XhrLike} The XHR stub that will be returned from the factory.
@suppress {checkTypes} suppression added to enable type checking