code: function parseErrorResponse(response, body) {
      const httpStatus = response.statusCode;
      const contentType = getResponseContentType(response);
  
      let err;
      if (contentType) {
          if (contentType.type === 'application/json') {
              err = new module.exports.MatrixError(JSON.parse(body));
          } else if (contentType.type === 'text/plain') {
              err = new Error(`Server returned ${httpStatus} error: ${body}`);
          }
      }
  
      if (!err) {
          err = new Error(`Server returned ${httpStatus} error`);
      }
      err.httpStatus = httpStatus;
      return err;
  }
docs: Attempt to turn an HTTP error response into a Javascript Error.
  
  If it is a JSON response, we will parse it into a MatrixError. Otherwise
  we return a generic Error.
  
  @param {XMLHttpRequest|http.IncomingMessage} response response object
  @param {String} body raw body of the response
  @returns {Error}