LocalGitDBImpl.branch: rewrite without try/catch block

This commit is contained in:
Paul Campbell 2018-07-10 22:50:11 +01:00
parent 32027ef6e1
commit 436a3e2501

View file

@ -112,13 +112,9 @@ final class LocalGitDBImpl implements GitDB, LocalGitDB {
@Override @Override
public Result<Maybe<GitDBBranch>> branch(final String name) { public Result<Maybe<GitDBBranch>> branch(final String name) {
try { return Result.maybeThen(
return Result.invert(Maybe.maybe( Result.of(() -> Maybe.maybe(repository.findRef(name))),
repository.findRef(name)) refMaybe -> Result.invert(refMaybe.map(branchInit)));
.map(branchInit::apply));
} catch (IOException e) {
return Result.error(e);
}
} }
} }