From 436a3e2501b41869b3394baedb3137f80c8dec63 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jul 2018 22:50:11 +0100 Subject: [PATCH] LocalGitDBImpl.branch: rewrite without try/catch block --- .../java/net/kemitix/gitdb/impl/LocalGitDBImpl.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/kemitix/gitdb/impl/LocalGitDBImpl.java b/src/main/java/net/kemitix/gitdb/impl/LocalGitDBImpl.java index 9164a96..140bd5f 100644 --- a/src/main/java/net/kemitix/gitdb/impl/LocalGitDBImpl.java +++ b/src/main/java/net/kemitix/gitdb/impl/LocalGitDBImpl.java @@ -112,13 +112,9 @@ final class LocalGitDBImpl implements GitDB, LocalGitDB { @Override public Result> 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))); } }