Browse Source

Throw CorruptObjectException when a bad object is found

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

Change-Id: I829431c38c71fa1899e33916252b75f09db8ecbd
tags/v3.4.0.201405051725-m7
Shawn Pearce 10 years ago
parent
commit
8924d4e0a0

+ 15
- 0
org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java View 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);
}
}

+ 4
- 3
org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java View 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);
}
}


Loading…
Cancel
Save