From 4895350c6bc85b2c5bf82fbc9d2829406aec7fab Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 2 Jun 2018 10:59:52 +0100 Subject: [PATCH] Improve error message for GitDbRepoNotFoundException --- src/main/java/net/kemitix/gitdb/GitDB.java | 2 +- ...FoundException.java => GitDBRepoNotFoundException.java} | 7 +++---- src/test/java/net/kemitix/gitdb/GitDBTest.java | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/main/java/net/kemitix/gitdb/{GitDbRepoNotFoundException.java => GitDBRepoNotFoundException.java} (65%) diff --git a/src/main/java/net/kemitix/gitdb/GitDB.java b/src/main/java/net/kemitix/gitdb/GitDB.java index d82a86b..9a4bbb1 100644 --- a/src/main/java/net/kemitix/gitdb/GitDB.java +++ b/src/main/java/net/kemitix/gitdb/GitDB.java @@ -53,7 +53,7 @@ public interface GitDB { final Git git = Git.open(dbDir.toFile()); return new GitDBLocal(git); } catch (RepositoryNotFoundException e) { - throw new GitDbRepoNotFoundException(dbDir, e); + throw new GitDBRepoNotFoundException(dbDir, e); } } } diff --git a/src/main/java/net/kemitix/gitdb/GitDbRepoNotFoundException.java b/src/main/java/net/kemitix/gitdb/GitDBRepoNotFoundException.java similarity index 65% rename from src/main/java/net/kemitix/gitdb/GitDbRepoNotFoundException.java rename to src/main/java/net/kemitix/gitdb/GitDBRepoNotFoundException.java index d91faed..23eed66 100644 --- a/src/main/java/net/kemitix/gitdb/GitDbRepoNotFoundException.java +++ b/src/main/java/net/kemitix/gitdb/GitDBRepoNotFoundException.java @@ -9,15 +9,14 @@ import java.nio.file.Path; * * @author Paul Campbell (pcampbell@kemitix.net) */ -public class GitDbRepoNotFoundException extends RuntimeException { +public class GitDBRepoNotFoundException extends RuntimeException { /** * Constructor. * - * @param path the path that is not a valid GitDB repo * @param cause the original exception */ - GitDbRepoNotFoundException(final Path path, final RepositoryNotFoundException cause) { - super(cause); + GitDBRepoNotFoundException(final Path path, final RepositoryNotFoundException cause) { + super(String.format("GitDB repo not found: %s", path.toString()), cause); } } diff --git a/src/test/java/net/kemitix/gitdb/GitDBTest.java b/src/test/java/net/kemitix/gitdb/GitDBTest.java index e007d8a..7619bbb 100644 --- a/src/test/java/net/kemitix/gitdb/GitDBTest.java +++ b/src/test/java/net/kemitix/gitdb/GitDBTest.java @@ -122,8 +122,9 @@ class GitDBTest implements WithAssertions { //given final Path dir = dirExists(); //then - assertThatExceptionOfType(GitDbRepoNotFoundException.class) + assertThatExceptionOfType(GitDBRepoNotFoundException.class) .isThrownBy(() -> GitDB.openLocal(dir)) + .withMessageContaining("GitDB repo not found") .withMessageContaining(dir.toString()); }