Improve error message for GitDbRepoNotFoundException

This commit is contained in:
Paul Campbell 2018-06-02 10:59:52 +01:00
parent 18e9d51248
commit 4895350c6b
3 changed files with 6 additions and 6 deletions

View file

@ -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);
}
}
}

View file

@ -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);
}
}

View file

@ -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());
}