Вы должны связывать исключения и не работать с классом исключений верхнего уровня. GitAPIException выбрасывается при клонировании.Вы можете сначала попытаться отловить возможные случаи и позволить основному исключению иметь дело с отдыхом.
public static <R>R handleClone(String uri,File local,boolean bare,Function<Git,R> fn){
try {
Git g=Git.cloneRepository().setURI(uri).setBare(bare).setDirectory(local).call();
return handle(g,fn);
}
catch ( GitAPIException e) {
throw new IllegalStateException(e);
}
}
Пример цепочки исключений:
catch ( IOException e) {
return new Status(IStatus.ERROR,GitActivator.PI_GIT,"Error cloning git repository",e);
}
catch ( CoreException e) {
return e.getStatus();
}
catch ( GitAPIException e) {
return getGitAPIExceptionStatus(e,"Error cloning git repository");
}
catch ( JGitInternalException e) {
return getJGitInternalExceptionStatus(e,"Error cloning git repository");
}
catch ( Exception e) {
return new Status(IStatus.ERROR,GitActivator.PI_GIT,"Error cloning git repository",e);
}
return Status.OK_STATUS;
}