From 1a9c3a1a6c4783bcee21f25efda1cabb26a07909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Fri, 23 Nov 2018 15:56:35 +0100 Subject: [PATCH] Use meaningful exception --- .../java/sonia/scm/repository/xml/XmlRepositoryDAO.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java index e4b012d55a..e7d3a84d41 100644 --- a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java +++ b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java @@ -35,6 +35,7 @@ package sonia.scm.repository.xml; import com.google.inject.Inject; import com.google.inject.Singleton; +import sonia.scm.NotFoundException; import sonia.scm.SCMContextProvider; import sonia.scm.io.FileSystem; import sonia.scm.repository.InitialRepositoryLocationResolver; @@ -51,6 +52,8 @@ import java.nio.file.Path; import java.util.Collection; import java.util.Optional; +import static sonia.scm.ContextEntry.ContextBuilder.entity; + /** * @author Sebastian Sdorra */ @@ -187,7 +190,7 @@ public class XmlRepositoryDAO return p.getId(); } } - throw new RuntimeException("could not find repository for directory: " + path); + throw new NotFoundException("directory", path.getPath()); } private Path toRealPath(Path path) { @@ -196,7 +199,7 @@ public class XmlRepositoryDAO // (see issue #82, https://bitbucket.org/sdorra/scm-manager/issues/82/symbolic-link-in-hg-repository-path) return path.toRealPath(); } catch (IOException e) { - throw new RuntimeException("could not get Path$toRealPath for path: " + path); + throw new InternalRepositoryException(entity("directory", path.toString()), "could not get Path$toRealPath for path: " + path); } }