Browse Source

Throw CorruptObjectException when a bad object is found

This makes it easier to identify higher in the call stack.

Change-Id: I829431c38c71fa1899e33916252b75f09db8ecbd
stable-3.4
Shawn Pearce 11 years ago
parent
commit
8924d4e0a0
  1. 15
      org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java
  2. 7
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java

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

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

Loading…
Cancel
Save