You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Er...@inventivedesigners.com on 2003/03/17 09:38:28 UTC

Extensions and error conditions

I was just wondering, how should an extension deal with error conditions.
Should an extension just throw an exception (assuming it's written in java)
or are there other mechanisms ?

As a simple example, suppose that the SQL extension where unable to reach
the database (something went wrong, for instance no Driver found on the
classpath), chances are the resulting xml file will contain rubbish. If
this were to happen during a sequence of stylesheet transformations, it
would be nice if Xalan could abort user code linking the sequence together.

I probably just overlooked something in the documentation

Cheers,
Erik

---------

Erik Vanherck  -  System Programmer & Designer
Inventive Designers
Visit http://www.inventivedesigners.com
Visist http://www.inventivedesigners.com/scriptura for Scriptura
information !

Phone: +32 - 3 - 8210170
Fax: +32 - 3 - 8210171
Email: Erik_Vanherck@inventivedesigners.com

"Computers in the future may weigh no more than 1.5 tons." - Popular
Mechanics, forecasting the relentless march of science, 1949


Re: Extensions and error conditions

Posted by Joseph Kesselman <ke...@us.ibm.com>.
>I was just wondering, how should an extension deal with error conditions.
>Should an extension just throw an exception (assuming it's written in 
java)
>or are there other mechanisms ?

Throwing an exception is certainly simplest. The extension mechanism 
should (though I haven't re-checked whether it does) catch them and give 
the Error Handler a chance to process them before treating them as fatal 
errors. Most of our standard extensions do this.

If you want to report a nonfatal error/warning, or report an error that 
you might want to continue pass... that's trickier, and not as clean as it 
should be. You need to take the ExpressionContext, call its 
getXPathContext() method, , use that object's getErrorListener() method 
and then call the appropriate method on that object to actually report the 
problem.

(There are comments in the code reminding us that we really ought to 
formally architect how extensions report errors, when we get a Round 
Tuit...)

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more. 
"may'ron DaroQbe'chugh vaj bIrIQbej"  ("Put down the squeezebox and nobody 
gets hurt.")