[xsd-users] Fwd: Extended exception information

Boris Kolpackov boris at codesynthesis.com
Fri Apr 17 04:45:19 EDT 2009


Hi David,

David White <dawhite32 at gmail.com> writes:

>   ::xsd::cxx::parser::diagnostics<char>::const_iterator _it =
> e.diagnostics().begin();

It is cleaner to use the xml_schema::diagnostics alias.


>   for (_it; _it!=e.diagnostics().end(); _it++)
>   {
>     ss << endl;
>     ss << "  - line " << _it->line();
>     ss << ", column " <<  _it->column();
>     ss << ", severity " <<  _it->severity() << endl;
>     ss << "  - " << _it->message();
>   }

You can do it this way if you want custom formatting. Otherwise, you
can just print the exception:

catch (const xml_schema::exception& e)
{
  cerr << e << endl;
}

This is what all the examples do. See Section 7.3, "Error Handling"
in the C++/Parser Mapping Getting Started Guide for more details:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#7.3

Boris




More information about the xsd-users mailing list