StoredObjectRepresentationNotAvailableException: Add constructor that takes cause

If the cause can be passed into the constructor, callers don't need to
instantiate it and then explicitly call initCause.

Note that the constructors in this class cause "non-API parameter type"
warnings because ObjectToPack is internal, however it's probably OK
since the only non-internal reference to it is in the pgm.debug package.

Change-Id: Ia4eab24e79f9afe6214ea8160137d941d4048319
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2017-12-18 14:34:13 +09:00
parent 1e141469f1
commit 5e7eed41f6
2 changed files with 17 additions and 4 deletions

View File

@ -61,4 +61,19 @@ public class StoredObjectRepresentationNotAvailableException extends Exception {
public StoredObjectRepresentationNotAvailableException(ObjectToPack otp) {
// Do nothing.
}
/**
* Construct an error for an object.
*
* @param otp
* the object whose current representation is no longer present.
* @param cause
* cause
* @since 4.10
*/
public StoredObjectRepresentationNotAvailableException(ObjectToPack otp,
Throwable cause) {
super(cause);
// Do nothing.
}
}

View File

@ -533,10 +533,8 @@ void copyAsIs(PackOutputStream out, DfsObjectToPack src,
try {
readFully(src.offset, buf, 0, 20, ctx);
} catch (IOException ioError) {
StoredObjectRepresentationNotAvailableException gone;
gone = new StoredObjectRepresentationNotAvailableException(src);
gone.initCause(ioError);
throw gone;
throw new StoredObjectRepresentationNotAvailableException(src,
ioError);
}
int c = buf[0] & 0xff;
final int typeCode = (c >> 4) & 7;