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
public Result<Maybe<GitDBBranch>> branch(final String name) {
try {
return Result.invert(Maybe.maybe(
repository.findRef(name))
.map(branchInit::apply));
} catch (IOException e) {
return Result.error(e);
}
return Result.maybeThen(
Result.of(() -> Maybe.maybe(repository.findRef(name))),
refMaybe -> Result.invert(refMaybe.map(branchInit)));
}
}