OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] SAXException, checked, buy why?

[ Lists Home | Date Index | Thread Index ]

Alan Gutierrez wrote:


>>Maybe in that case event handlers should avoid throwing
>>exceptions at all, and rather notify an error handler.
> 
> 
>     Agreed.
>     
>     Please consider my idea again.
> 
>     Assume at the SAX content handler author, and the SAX
>     application author are two different entities. That the SAX
>     content handler cannot anticipate how exceptions should be
>     handled.
> 
>     What is the design of an API for exception handling within the
>     content handler? Within the observer of an observer pattern?
> 
>     I proposed on in an earlier message:
> 
>     public interface SAXCassandra {
>         public void error (SAXError saxError);
>     }

What makes this different from the ErrorHandler interface
already specified in SAX?

>     By implementing this observer, and handing it off to a content
>     handler, the application developer can inspect errors before they
>     are thrown.
> 
>     The sax filter author writes:
> 
>     public void startElement(
>         String ns, String ln, String qn, Attributes as
>     ) {
>       if (ln.equals("foo")) {
>         FileInputStream in = null;
>         String fileName = as.getValue("file-name");
>         do {
>           try {
>             in = new FileInputStream(new File(fileName));
>           } catch (FileNotFoundException e) {
>             this.cassandra.error(new SAXError(e));
>           }
>         } while (in == null);
>       }
>     }
> 
>     The above probably wouldn't give the application author enough
>     information to recover from the error, but we can fix that by
>     creating a special SAXError, or wrapping a Foo specific
>     exception that includes the file name.

All agreed, but see my question above.
(Maybe I am still slow on the uptake because I celebrated too
much on New Year's eve ;-) )

Karl




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS