From: Nick Burch Date: Thu, 31 Jul 2008 13:21:57 +0000 (+0000) Subject: More helpful error messages when you try to give POIFS an OOXML file X-Git-Tag: REL_3_5_BETA2~41 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b6af19763e533e20412288cce9e7b27f3e602642;p=poi.git More helpful error messages when you try to give POIFS an OOXML file git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@681365 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java b/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java index b001b81058..a816e65045 100644 --- a/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java +++ b/src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java @@ -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 diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java b/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java index 8080b3ec79..7de2841d4d 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java @@ -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); } }