static handleRequest(request, onDone, onError) {
    request
        .done(function(data) {
          if (data && data.error) {
            onError(data.error);
          } else {
            if (onDone) onDone(data);
          }
        })
        .fail(function(_, textStatus) {
          onError(textStatus);
        });
    return request;
  }
Handles the success or failure of the data request.
@param {Object} request The jqXHR sent.
@param {function(Object)} onDone The function to call if the request
    succeeds, with the data object as an argument.
@param {function(string)} onError The function to call if the request
    fails, with an error message as an argument.
@return {Object} The original request, against which further callbacks
    can be registered.