[xsd-users] xerces exceptions

Boris Kolpackov boris at codesynthesis.com
Wed May 12 13:08:29 EDT 2010


Hi Leonid,

Leonid Gershanovich <gleonid at yahoo.com> writes:

> Also there is a group of exceptions that has a common parent 
> (xsd::cxx::parser::schema_exception), but not derived from 
> std::exception:
> 	1. xsd::cxx::parser::dynamic_type<C> 
> 	2. xsd::cxx::parser::validating::expected_attribute<C> 
> 	3. xsd::cxx::parser::expected_element<C> 
> 	4. xsd::cxx::parser::validating::invalid_value<C> 
> 	5. xsd::cxx::parser::validating::unexpected_attribute<C> 
> 	6. xsd::cxx::parser::validating::unexpected_characters<C> 
> 	7. xsd::cxx::parser::unexpected_element<C>

These are internal C++/Parser exception. They never rich the user code
and instead are translated to the error handler calls. They are not
derived from std::exception since that would simply add more overhead
without any benefit.


> And there is another set of exceptions, which are essentially an 
> empty struct declarations:
> 	1. xsd::cxx::xml::sax::std_input_source::copy {} 
> 	2. xsd::cxx::xml::properties<typename C>::argument {} 
> 	3. xsd::cxx::parser::buffer::bounds {} 
> 	4. xsd::cxx::xml::invalid_utf16_string {} 
> 	5. xsd::cxx::xml::invalid_utf8_string {}
>
> [...]
>
> So my questions are:
> 1. Have you considered to make all exceptions in CodeSynthesis to 
> be derived from std::exception?

Yes, these should be derived from xsd::exception (which derives 
from std::exception). I have an item in the TODO list for the 
next release.


> 2. What was the original reason not use std::exception?

The original reason for not deriving them from std::exception was 
that if any of these exceptions is thrown, it most likely means 
there is a bug in the program or XSD and the best course of action
is probably not to catch them and let the program terminate with 
some debug information. But, I agree, we (as in XSD developers),
shouldn't be making this decision. If the program needs to catch
all the exceptions we shouldn't be making it more difficult to do
so.

Thanks for preparing the detailed analysis of the current situation!

Boris



More information about the xsd-users mailing list