Re: [Saxdotnet-devel] Changing Exceptions in the API
Brought to you by:
jeffrafter,
kwaclaw
From: Elliotte H. <el...@me...> - 2004-12-12 03:08:37
|
Karl Waclawek wrote: > > In the .NET line of thinking we should probably get rid of both, > the SAXNotSupportedException and SAXNotRecognizedException, > as in both cases, what you really have is an invalid argument > (the name of a property or feature), which therefore should > throw a standard ArgumentException with a message (or code) indicating > "not supported" or "not recognized". > How significant is the difference anyway? I don't know what really makes sense exception wise in .NET. It's certainly plausible that you don't want to follow Java here. However there is an important difference between the SAXNotSupportedException and SAXNotRecognizedException, even if I always have trouble remembering which is which. Hoping I don't get these backwards (as I often do), SAXNotRecognizedException means that the parser will never allow you to set or read this feature/property. It's simply not available in this implementation. SAXNotSupportedException means something a little different. Either 1. You can't read/write the value of this property at the current time, but you might be able to later. For instance, you can't turn on validation when you're halfway through parsing a document. Only before you begin parsing a document or after you finish parsing one. 2. The specific value you tried to set is not supported. For instance, you passed an object that does not implement LexicalHandler as the value for the lexical-handler property, or you passed true for the validation feature with a parser that does not validate. By contrast, you might see a SAXNotRecognizedException if you tried to use a Xerces specific feature/property with AElfred or vice versa. It's a subtle distinction, but I do think it's valuable to maintain it. -- Elliotte Rusty Harold el...@me... XML in a Nutshell 3rd Edition Just Published! http://www.cafeconleche.org/books/xian3/ http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim |