OPC: add original IOException to chain on open file errors
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1302840 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c03bcf23d4
commit
c0571bdce3
@ -25,4 +25,8 @@ public class InvalidOperationException extends OpenXML4JRuntimeException{
|
||||
public InvalidOperationException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidOperationException(String message, Throwable reason){
|
||||
super(message, reason);
|
||||
}
|
||||
}
|
||||
|
@ -98,10 +98,15 @@ public final class ZipPackage extends Package {
|
||||
ZipPackage(String path, PackageAccess access) {
|
||||
super(access);
|
||||
|
||||
ZipFile zipFile = ZipHelper.openZipFile(path);
|
||||
if (zipFile == null)
|
||||
throw new InvalidOperationException(
|
||||
"Can't open the specified file: '" + path + "'");
|
||||
ZipFile zipFile = null;
|
||||
|
||||
try {
|
||||
zipFile = ZipHelper.openZipFile(path);
|
||||
} catch (IOException e) {
|
||||
throw new InvalidOperationException(
|
||||
"Can't open the specified file: '" + path + "'", e);
|
||||
}
|
||||
|
||||
this.zipArchive = new ZipFileZipEntrySource(zipFile);
|
||||
}
|
||||
|
||||
|
@ -148,15 +148,13 @@ public final class ZipHelper {
|
||||
* The file path.
|
||||
* @return The zip archive freshly open.
|
||||
*/
|
||||
public static ZipFile openZipFile(String path) {
|
||||
public static ZipFile openZipFile(String path) throws IOException {
|
||||
File f = new File(path);
|
||||
try {
|
||||
if (!f.exists()) {
|
||||
return null;
|
||||
}
|
||||
return new ZipFile(f);
|
||||
} catch (IOException ioe) {
|
||||
|
||||
if (!f.exists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ZipFile(f);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user