1 16 17 package org.apache.cocoon.generation; 18 19 import net.sourceforge.chaperon.process.ParseException; 20 21 import org.apache.cocoon.ProcessingException; 22 import org.apache.cocoon.environment.ObjectModelHelper; 23 24 import org.apache.commons.lang.exception.ExceptionUtils; 25 26 import org.exolab.castor.xml.MarshalException; 27 import org.exolab.castor.xml.Marshaller; 28 import org.exolab.castor.xml.ValidationException; 29 30 import org.xml.sax.SAXException ; 31 32 import java.io.IOException ; 33 34 39 public class ParseExceptionGenerator extends AbstractGenerator 40 { 41 public void generate() throws IOException , SAXException , ProcessingException 42 { 43 Throwable throwable = ObjectModelHelper.getThrowable(objectModel); 44 45 while ((!(throwable instanceof ParseException)) && 46 (ExceptionUtils.getCause(throwable)!=null)) 47 throwable = ExceptionUtils.getCause(throwable); 48 49 if (!(throwable instanceof ParseException)) 50 { 51 ((ParseException)throwable).toXML(super.contentHandler); 52 return; 53 } 54 55 Marshaller marshaller = new Marshaller(super.contentHandler); 56 57 try 58 { 59 marshaller.marshal(throwable); 60 } 61 catch (MarshalException me) 62 { 63 throw new ProcessingException(me); 64 } 65 catch (ValidationException ve) 66 { 67 throw new ProcessingException(ve); 68 } 69 } 70 } 71 | Popular Tags |