]> source.dussan.org Git - poi.git/commitdiff
Throw a more useful exception in the case of word95 documents
authorNick Burch <nick@apache.org>
Thu, 10 Aug 2006 12:20:24 +0000 (12:20 +0000)
committerNick Burch <nick@apache.org>
Thu, 10 Aug 2006 12:20:24 +0000 (12:20 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@430365 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java

index 468c4a95c8b9fd92d53952e79c34ef651aad3b7a..c525c572362d4d4cf55b293f818a285377798380 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.hwpf;
 
 import java.io.InputStream;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.PushbackInputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -153,9 +154,16 @@ public class HWPFDocument extends POIDocument
       name = "1Table";
     }
 
+    // Grab the table stream.
+    DocumentEntry tableProps;
+       try {
+               tableProps =
+                       (DocumentEntry)filesystem.getRoot().getEntry(name);
+       } catch(FileNotFoundException fnfe) {
+               throw new IllegalStateException("Table Stream '" + name + "' wasn't found - Either the document is corrupt, or is Word95 (or earlier)");
+       }
+
     // read in the table stream.
-    DocumentEntry tableProps =
-      (DocumentEntry)filesystem.getRoot().getEntry(name);
     _tableStream = new byte[tableProps.getSize()];
     filesystem.createDocumentInputStream(name).read(_tableStream);