diff options
author | Shawn Pearce <spearce@spearce.org> | 2014-04-03 10:10:01 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2014-04-03 11:12:01 -0700 |
commit | 8924d4e0a09ea792123a892ba2b7d2c0bfd11946 (patch) | |
tree | 4fed03b4269760a5de082df915ebad0cc5ae6e02 /org.eclipse.jgit/src | |
parent | 90d743f83433ad4a8235ef001b571ce472e3e57c (diff) | |
download | jgit-8924d4e0a09ea792123a892ba2b7d2c0bfd11946.tar.gz jgit-8924d4e0a09ea792123a892ba2b7d2c0bfd11946.zip |
Throw CorruptObjectException when a bad object is found
This makes it easier to identify higher in the call stack.
Change-Id: I829431c38c71fa1899e33916252b75f09db8ecbd
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java | 15 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java | 7 |
2 files changed, 19 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java index 610423353b..c6ea093750 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java @@ -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); + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java index 93522c1e92..4f53d22670 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java @@ -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); } } |