Skip to content

Commit

Permalink
make exception throwing more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Jan 19, 2024
1 parent c179587 commit 18431b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/github/pjfanning/xlsx/XmlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static Document readDocument(InputStream inp) throws IOException, SAXExce
return DocumentHelper.readDocument(inp);
}

public static NodeList searchForNodeList(Document document, String xpath) {
public static NodeList searchForNodeList(Document document, String xpath) throws ParseException {
try {
XPath xp = XPathFactory.newInstance().newXPath();
xp.setNamespaceContext(transitionalFormatNamespaceContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.pjfanning.xlsx.impl.ooxml;

import com.github.pjfanning.xlsx.exceptions.ReadException;
import org.apache.poi.util.Beta;

import java.io.*;
Expand Down Expand Up @@ -34,7 +35,7 @@ public static Properties readMappings() {

}
} catch (IOException e) {
throw new RuntimeException(e);
throw new ReadException("Failed to read mappings", e);
}
return props;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public class OoxmlReader extends XSSFReader {
*/
@Internal
public OoxmlReader(StreamingReader.Builder builder,
OPCPackage pkg, boolean strictOoxmlChecksNeeded) throws IOException, OpenXML4JException {
OPCPackage pkg, boolean strictOoxmlChecksNeeded)
throws IOException, OpenXML4JException, POIXMLException {
super(pkg, true);

PackageRelationship coreDocRelationship = this.pkg.getRelationshipsByType(
Expand Down Expand Up @@ -183,9 +184,12 @@ static class OoxmlSheetReader {
* Construct a new SheetIterator
*
* @param wb package part holding workbook.xml
* @throws IOException if reading the data from the package fails
* @throws POIXMLException if the package data is invalid
*/
OoxmlSheetReader(final StreamingReader.Builder builder,
final PackagePart wb, final boolean strictOoxmlChecksNeeded) throws IOException {
final PackagePart wb, final boolean strictOoxmlChecksNeeded)
throws IOException, POIXMLException {
this.builder = builder;
this.strictOoxmlChecksNeeded = strictOoxmlChecksNeeded;
/*
Expand Down Expand Up @@ -245,7 +249,7 @@ SheetData getSheetData(final XSSFSheetRef sheetRef) {
return sd;
}

private ArrayList<XSSFSheetRef> createSheetListFromWB(PackagePart wb) throws IOException {
private ArrayList<XSSFSheetRef> createSheetListFromWB(PackagePart wb) throws IOException, OpenException, POIXMLException {

XMLSheetRefReader xmlSheetRefReader = new XMLSheetRefReader();
XMLReader xmlReader;
Expand Down

0 comments on commit 18431b9

Please sign in to comment.