this.callback = callback;
}
@Override
public void onFailure(ErrorOutput.ErrorBody e, HttpHeaders responseHeaders) throws IOException {
GoogleJsonErrorContainer errorContainer = new GoogleJsonErrorContainer();
if (e.hasError()) {
ErrorOutput.ErrorProto errorProto = e.getError();
GoogleJsonError error = new GoogleJsonError();
if (errorProto.hasCode()) {
error.setCode(errorProto.getCode());
}
if (errorProto.hasMessage()) {
error.setMessage(errorProto.getMessage());
}
List<ErrorInfo> errorInfos = new ArrayList<ErrorInfo>(errorProto.getErrorsCount());
for (ErrorOutput.IndividualError individualError : errorProto.getErrorsList()) {
ErrorInfo errorInfo = new ErrorInfo();
if (individualError.hasDomain()) {
errorInfo.setDomain(individualError.getDomain());
}
if (individualError.hasMessage()) {
errorInfo.setMessage(individualError.getMessage());
}
if (individualError.hasReason()) {
errorInfo.setReason(individualError.getReason());
}
errorInfos.add(errorInfo);
}
error.setErrors(errorInfos);
errorContainer.setError(error);
}
callback.onFailure(errorContainer, responseHeaders);
}