[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: SAXException, checked, buy why?
* Karl Waclawek <karl@w...> [2005-01-03 11:14]: > 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? public interface ErrorHandler { public void error(SAXParseException exception) throws SAXException; public void fatalError(SAXParseException exception) throws SAXException; public void warning(SAXParseException exception) throws SAXException; } It is meant to respond to errors in parse, not errors in content handling. If content handler authors were to adopt it for use as a means to intercept genral errors, they'd be going against the documented use. http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html > > 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 ;-) ) No. You're asking the questions I asked myself. -- Alan Gutierrez - alan@e...
|
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
|