parseJson = (body) => {
    try {
      const response = JSON.parse(body);
      if (goog.isObject(response)) {
        if ('error' in response && 'message' in response['error'] &&
           !(detectPartialError && detectPartialError(response))) {
          return response['error']['message'];
        }
      }
      return {parsed: response};
    } catch (e) {
      if (body === '') {
        // XHR returns an empty string for large responses (>100 MB) or when
        // there is a network error. Handle this case in the caller.
        return '';
      }
      return 'Invalid JSON: ' + body;
    }
  }
Handles processing and dispatching a callback response.
@param {number} status The status code of the response.
@param {function(string):?string} getResponseHeader A function for
    getting the value of a response headers for a given header name.
@param {string} responseText The text of the response.
@param {?function(string)} profileHook The profile hook at the time the
    request was created.
@param {function(?,string=)=} callback An optional callback to
    execute if the request is asynchronous.
@param {string=} url The request's URL.
@param {string=} method The request's HTTP method.
@param {function(!Object):boolean=} detectPartialError Checks if response
    JSON should be returned directly instead of throwing an error.
@return {?Object} The response data, if the request is synchronous,
    otherwise null, if the request is asynchronous.
@private