[xsde-users] Feature proposal : throw an exception when accessing non-present member

Ivan Le Lann ivan.lelann at free.fr
Fri Jan 28 09:24:32 EST 2011

Hi all,

Here is the typical generated code for a variable length member.

    ::bar_type& foo_type::
    bar ()
      return *this->bar_;

Obviously, calling bar() when bar_present() is false is an access violation.
For a fix length member, you get something between a random value or a default one.
I consider current behavior as both inconsistent and tricky.

Now, how about throwing an exception with very basic information?
I dislike having to do C-style checks to show decent error report.
The concern is mostly for variable length elements but I'd vote for consistency.

Should this proposal meet success, I'd be glad to help with an implementation.
This should probably be an option, conflicting with no-exception, and whose default 
value has to be carefully chosen.

Now one question is left wide open:
How to apply this to mandatory elements/attributes?
One could consider XML validation exceptions sufficient for those,
but that would keep the process of building from scratch hazardous ...


More information about the xsde-users mailing list