diff options
Diffstat (limited to 'src/java/org/apache/fop/render/intermediate/IFParser.java')
-rw-r--r-- | src/java/org/apache/fop/render/intermediate/IFParser.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index 61d1838bc..92e71d105 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -79,15 +79,29 @@ public class IFParser implements IFConstants { * @param documentHandler the intermediate format document handler used to process the IF events * @param userAgent the user agent * @throws TransformerException if an error occurs while parsing the area tree XML + * @throws IFException if an IF-related error occurs inside the target document handler */ public void parse(Source src, IFDocumentHandler documentHandler, FOUserAgent userAgent) - throws TransformerException { - Transformer transformer = tFactory.newTransformer(); - transformer.setErrorListener(new DefaultErrorListener(log)); - - SAXResult res = new SAXResult(getContentHandler(documentHandler, userAgent)); - - transformer.transform(src, res); + throws TransformerException, IFException { + try { + Transformer transformer = tFactory.newTransformer(); + transformer.setErrorListener(new DefaultErrorListener(log)); + + SAXResult res = new SAXResult(getContentHandler(documentHandler, userAgent)); + + transformer.transform(src, res); + } catch (TransformerException te) { + //Unpack original IFException if applicable + if (te.getCause() instanceof SAXException) { + SAXException se = (SAXException)te.getCause(); + if (se.getCause() instanceof IFException) { + throw (IFException)se.getCause(); + } + } else if (te.getCause() instanceof IFException) { + throw (IFException)te.getCause(); + } + throw te; + } } /** |