]> source.dussan.org Git - jgit.git/commitdiff
Throw CorruptObjectException when a bad object is found 07/24407/2
authorShawn Pearce <spearce@spearce.org>
Thu, 3 Apr 2014 17:10:01 +0000 (10:10 -0700)
committerShawn Pearce <spearce@spearce.org>
Thu, 3 Apr 2014 18:12:01 +0000 (11:12 -0700)
This makes it easier to identify higher in the call stack.

Change-Id: I829431c38c71fa1899e33916252b75f09db8ecbd

org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java

index 610423353bf204e5fc8be5261c1a79615f9ab79c..c6ea0937505253eb371c03645048b78e2ecb595c 100644 (file)
@@ -90,4 +90,19 @@ public class CorruptObjectException extends IOException {
        public CorruptObjectException(final String why) {
                super(why);
        }
+
+       /**
+        * Construct a CorruptObjectException for reporting a problem not associated
+        * with a specific object id.
+        *
+        * @param why
+        *            message describing the corruption.
+        * @param cause
+        *            optional root cause exception
+        * @since 3.4
+        */
+       public CorruptObjectException(String why, Throwable cause) {
+               super(why);
+               initCause(cause);
+       }
 }
index 93522c1e923c5ea227c1fba3a8b1ae0189d151a0..4f53d22670de07b3aa91c0c5cf9c7b5da9c07ea3 100644 (file)
@@ -1014,9 +1014,10 @@ public abstract class PackParser {
                        try {
                                objCheck.check(type, data);
                        } catch (CorruptObjectException e) {
-                               throw new IOException(MessageFormat.format(
-                                               JGitText.get().invalidObject, Constants
-                                                               .typeString(type), id.name(), e.getMessage()));
+                               throw new CorruptObjectException(MessageFormat.format(
+                                               JGitText.get().invalidObject,
+                                               Constants.typeString(type),
+                                               id.name(), e.getMessage()), e);
                        }
                }