]> source.dussan.org Git - jgit.git/commitdiff
LfsProtocolServlet: Improve error on getLargeFileRepository failure 04/88604/3
authorDavid Pursehouse <david.pursehouse@gmail.com>
Fri, 13 Jan 2017 01:41:27 +0000 (10:41 +0900)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 13 Jan 2017 23:05:56 +0000 (00:05 +0100)
Externalize the error message and make it more specific. Also emit
an error log.

Change-Id: Ie7b1c90c54673bfb8e133fb0aa19a117d4ca6587
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
org.eclipse.jgit.lfs/resources/org/eclipse/jgit/lfs/internal/LfsText.properties
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java

index 554b223a1714cce9357dcbf171b50b4be9b47fde..08cc189351c195a61579c7b56a6feec8f382a872 100644 (file)
@@ -33,4 +33,5 @@ Import-Package: com.google.gson;version="[2.2.4,3.0.0)",
  org.eclipse.jgit.nls;version="[4.7.0,4.8.0)",
  org.eclipse.jgit.transport.http;version="[4.7.0,4.8.0)",
  org.eclipse.jgit.transport.http.apache;version="[4.7.0,4.8.0)",
- org.eclipse.jgit.util;version="[4.7.0,4.8.0)"
+ org.eclipse.jgit.util;version="[4.7.0,4.8.0)",
+ org.slf4j;version="[1.7.0,2.0.0)"
index 0dffb8df0b2b4a3c2d693e57dea99482faeeb7ab..b741693fd6866c582336bd814726791c6c75db41 100644 (file)
@@ -59,6 +59,7 @@ import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
+import java.text.MessageFormat;
 import java.util.List;
 
 import javax.servlet.ServletException;
@@ -75,6 +76,9 @@ import org.eclipse.jgit.lfs.errors.LfsRepositoryReadOnly;
 import org.eclipse.jgit.lfs.errors.LfsUnauthorized;
 import org.eclipse.jgit.lfs.errors.LfsUnavailable;
 import org.eclipse.jgit.lfs.errors.LfsValidationError;
+import org.eclipse.jgit.lfs.internal.LfsText;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.gson.FieldNamingPolicy;
 import com.google.gson.Gson;
@@ -88,6 +92,8 @@ import com.google.gson.GsonBuilder;
  * @since 4.3
  */
 public abstract class LfsProtocolServlet extends HttpServlet {
+       private static Logger LOG = LoggerFactory
+                       .getLogger(LfsProtocolServlet.class);
 
        private static final long serialVersionUID = 1L;
 
@@ -183,7 +189,10 @@ public abstract class LfsProtocolServlet extends HttpServlet {
                try {
                        repo = getLargeFileRepository(request, path);
                        if (repo == null) {
-                               throw new LfsException("unexpected error"); //$NON-NLS-1$
+                               String error = MessageFormat
+                                               .format(LfsText.get().lfsFailedToGetRepository, path);
+                               LOG.error(error);
+                               throw new LfsException(error);
                        }
                        res.setStatus(SC_OK);
                        TransferHandler handler = TransferHandler
index aa089da113c2be091176adfe0f3f2de26b412795..e08e28cc55eea4ebc532ec6a54beff7dee454702 100644 (file)
@@ -8,3 +8,4 @@ repositoryNotFound=Repository {0} not found
 repositoryReadOnly=Repository {0} is read-only
 lfsUnavailable=LFS is not available for repository {0}
 lfsUnathorized=Not authorized to perform operation {0} on repository {1}
+lfsFailedToGetRepository=failed to get repository {0}
index 4260fcd0cd2af904280ea13ad434ef146e3ede91..44595887c4d8db4ca1396c28a7a274b75cd37745 100644 (file)
@@ -68,4 +68,5 @@ public class LfsText extends TranslationBundle {
        /***/ public String repositoryReadOnly;
        /***/ public String lfsUnavailable;
        /***/ public String lfsUnathorized;
+       /***/ public String lfsFailedToGetRepository;
 }