cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Gallardo <agalla...@agssa.net>
Subject Re: "xsltc" transformer masks exceptions from CIncluded resources
Date Wed, 27 Feb 2008 16:37:30 GMT
Hi Tobia,

I would like to include the patch to cocoon. One question: Does work the 
the patch for "xslt" and "xsltc" or just for the latter?

Best Regards,

Antonio Gallardo

Tobia Conforto escribió:
> Thank you for your insight.
>
> Actually XSLTC does preserve the cause, but it's wrapped in 
> TransformerExceptions.
> I managed to solve the issue by patching TraxTransformer so that it 
> removes wrapping exceptions (of SAXException and TransformerException 
> type, arbitrarily nested) before re-throwing the core exception.
>
> I will leave it to this list to figure out if it's a useful patch to 
> merge in Cocoon.
> It certainly makes the XSLTC transformer much more useable.
>
> But maybe there's a better place to put this un-wrapping code?
>
>
> Tobia
>
>
> --- transformation/TraxTransformer.orig 2008-02-26 18:28:23.000000000 
> +0100
> +++ transformation/TraxTransformer.java 2008-02-27 13:28:27.000000000 
> +0100
> @@ -29,6 +29,7 @@
>
>  import javax.xml.transform.sax.SAXResult;
>  import javax.xml.transform.sax.TransformerHandler;
> +import javax.xml.transform.TransformerException;
>
>  import org.apache.avalon.framework.activity.Disposable;
>  import org.apache.avalon.framework.configuration.Configurable;
> @@ -586,8 +587,21 @@
>              super.endDocument();
>          } catch(Exception e) {
>
> -            Throwable realEx = this.errorListener.getThrowable();
> -            if (realEx == null) realEx = e;
> +            Throwable realEx = e;
> +            while (true) {
> +                if (realEx instanceof SAXException) {
> +                    Throwable nested = ((SAXException) 
> realEx).getException();
> +                    if (nested == null)
> +                        break;
> +                    realEx = nested;
> +                } else if (realEx instanceof TransformerException) {
> +                    Throwable nested = ((TransformerException) 
> realEx).getException();
> +                    if (nested == null)
> +                        break;
> +                    realEx = nested;
> +                } else
> +                    break;
> +            }
>
>              if (realEx instanceof RuntimeException) {
>                  throw (RuntimeException)realEx;


Mime
View raw message