]> source.dussan.org Git - poi.git/commitdiff
OPC: add original IOException to chain on open file errors
authorMaxim Valyanskiy <maxcom@apache.org>
Tue, 20 Mar 2012 11:21:23 +0000 (11:21 +0000)
committerMaxim Valyanskiy <maxcom@apache.org>
Tue, 20 Mar 2012 11:21:23 +0000 (11:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1302840 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidOperationException.java
src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java

index a2538a6d1932c0a974289fd41f9c2a97bc13c091..7a8338ed81785b6a7d0616d46be4c7074e0f012b 100644 (file)
@@ -25,4 +25,8 @@ public class InvalidOperationException extends OpenXML4JRuntimeException{
        public InvalidOperationException(String message){
                super(message);
        }
+
+    public InvalidOperationException(String message, Throwable reason){
+               super(message, reason);
+       }
 }
index bc65412bc77e5717d61c4a30ed9dc7a3b792f9cd..5ac16d3a0b4fa14188561ada04bae6fd695ee1aa 100644 (file)
@@ -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);
        }
 
index cbfd5a7ee55c5a7eba1599dc3e97ed27cef77fa0..e808dc61e9f2dcbf6fe651c6b0adb8f0e57e6b46 100644 (file)
@@ -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);
        }
 }