]> source.dussan.org Git - poi.git/commitdiff
More helpful error messages when you try to give POIFS an OOXML file
authorNick Burch <nick@apache.org>
Thu, 31 Jul 2008 13:21:57 +0000 (13:21 +0000)
committerNick Burch <nick@apache.org>
Thu, 31 Jul 2008 13:21:57 +0000 (13:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@681365 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java
src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java

index b001b8105857f8fb61b2c170ddd8597b89d5ad4a..a816e65045db4b8558db85f2a96134356216bdd6 100644 (file)
@@ -105,7 +105,7 @@ public class HeaderBlockReader
                                        _data[1] == OOXML_FILE_HEADER[1] && 
                                        _data[2] == OOXML_FILE_HEADER[2] &&
                                        _data[3] == OOXML_FILE_HEADER[3]) {
-                               throw new OfficeXmlFileException("The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents");
+                               throw new OfficeXmlFileException("The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)");
                        }
 
                        // Give a generic error
index 8080b3ec7913e8a1d02a8b265390b765c0cfaf20..7de2841d4dce1a861152ed628aca2fbc4b4470df 100644 (file)
@@ -41,7 +41,8 @@ public class TestOffice2007XMLException extends TestCase {
                        fail("expected exception was not thrown");
                } catch(OfficeXmlFileException e) {
                        // expected during successful test
-                       assertTrue(e.getMessage().indexOf("POI only supports OLE2 Office documents") > 0);
+                       assertTrue(e.getMessage().indexOf("The supplied data appears to be in the Office 2007+ XML") > -1);
+                       assertTrue(e.getMessage().indexOf("You are calling the part of POI that deals with OLE2 Office Documents") > -1);
                }
        }