mirror of https://github.com/apache/poi.git
Include actual found type in exception when encountering unexpected type of file in ExtractorFactory
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1859565 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b2130769b6
commit
1a3e69fe16
|
@ -167,7 +167,7 @@ public final class ExtractorFactory {
|
|||
case OOXML:
|
||||
return createExtractor(OPCPackage.open(is));
|
||||
default:
|
||||
throw new IllegalArgumentException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
|
||||
throw new IllegalArgumentException("Your InputStream was neither an OLE2 stream, nor an OOXML stream, found type: " + fm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.poi.ooxml.extractor.POIXMLTextExtractor;
|
|||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.openxml4j.opc.PackageAccess;
|
||||
import org.apache.poi.poifs.filesystem.FileMagic;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
|
||||
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
||||
|
@ -193,6 +194,11 @@ public class TestExtractorFactory {
|
|||
try (FileInputStream fis = new FileInputStream(txt);
|
||||
POITextExtractor ignored = poifs.apply(fis)) {
|
||||
fail("extracting from invalid package");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertTrue("Had: " + e,
|
||||
e.getMessage().contains(FileMagic.UNKNOWN.name()));
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue