Author: maxcom
Date: Tue Mar 20 11:21:23 2012
New Revision: 1302840

URL: http://svn.apache.org/viewvc?rev=1302840&view=rev
Log:
OPC: add original IOException to chain on open file errors

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

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidOperationException.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidOperationException.java?rev=1302840&r1=1302839&r2=1302840&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidOperationException.java
 (original)
+++ 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidOperationException.java
 Tue Mar 20 11:21:23 2012
@@ -25,4 +25,8 @@ public class InvalidOperationException e
        public InvalidOperationException(String message){
                super(message);
        }
+
+    public InvalidOperationException(String message, Throwable reason){
+               super(message, reason);
+       }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java?rev=1302840&r1=1302839&r2=1302840&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java Tue 
Mar 20 11:21:23 2012
@@ -98,10 +98,15 @@ public final class ZipPackage extends Pa
        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);
        }
 

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java?rev=1302840&r1=1302839&r2=1302840&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java 
(original)
+++ 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java 
Tue Mar 20 11:21:23 2012
@@ -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);
        }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to