[xsde-users] Feature proposal : throw an exception when
accessing non-present member
boris at codesynthesis.com
Mon Jan 31 10:16:07 EST 2011
Ivan Le Lann <ivan.lelann at free.fr> writes:
> Obviously, calling bar() when bar_present() is false is an access violation.
Or, more precisely, it is a programming error that leads to an access
violation. One should never call an optional member accessor without
first checking for its presence.
> Now, how about throwing an exception with very basic information?
I think that's a bad idea. This is a programming error, not an unexpected
condition. It will also negatively affect performance and object code
> I dislike having to do C-style checks to show decent error report.
Having the _present() accessor return false should no be an error. If it
is, then you should make this member required (in the schema).
More information about the xsde-users