use of com.meisolsson.githubsdk.model.ClientErrorResponse in project gh4a by slapperwan.
the class FileViewerActivity method loadFile.
private void loadFile(boolean force) {
RepositoryContentService service = ServiceFactory.get(RepositoryContentService.class, force);
service.getContents(mRepoOwner, mRepoName, mPath, mRef).map(ApiHelpers::throwOnFailure).map(Optional::of).onErrorResumeNext(error -> {
if (error instanceof ApiRequestException) {
ClientErrorResponse response = ((ApiRequestException) error).getResponse();
List<ClientErrorResponse.FieldError> errors = response != null ? response.errors() : null;
if (errors != null) {
for (ClientErrorResponse.FieldError fe : errors) {
if (fe.reason() == ClientErrorResponse.FieldError.Reason.TooLarge) {
openUnsuitableFileAndFinish();
return Single.just(Optional.absent());
}
}
}
}
return Single.error(error);
}).compose(makeLoaderSingle(ID_LOADER_FILE, force)).subscribe(result -> {
if (result.isPresent()) {
mContent = result.get();
onDataReady();
setContentEmpty(false);
} else {
setContentEmpty(true);
setContentShown(true);
}
}, this::handleLoadFailure);
}
Aggregations