[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: SAXException, checked, buy why?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|