Regarding these exceptions; it would have been immensely helpful if Fluent
could catch these errors before the mappings were passed on to NHibernate,
because the exceptions NHibernate throws are often completely
unintelligible, especially for someone not intimately familiar with the
XML HBM mappings.
If there is indeed a missing Id mapping, can't Fluent throw an exception
stating that? Another way around is to wrap NHibernate's exception as an
inner exception to a FluentException that contains a bit more
human-readable descriptions on what's going on and why the exception
occurred.
These mapping exceptions complaining about missing XML elements have
bitten me many times and are pretty hard to debug, imho.
-Asbjørn
I wonder how the exception handling inside NHibernate looks when stuff
like this bubbles up and hits the consumers of the library. I haven't had
a look at the code and I'm not sure where the best place to help improve
the exception situation is.
NHibernate itself seems to be in need of more exception handling and much
better error messages, while Fluent seems to be in need of wrapping all of
NHibernate's exceptions in more intelligble Fluent-related exceptions
and/or throwing its own exceptions before the error even hits NHibernate.
I'm not sure where to do what and qite frankly, I don't feel confident
enough with NHibernate to do it myself.
-Asbjørn
On Sun, 12 Jul 2009 13:43:39 +0200, Paul Batum <paul....@gmail.com>
wrote:
There's still one thing I don't quite understand, though: Isn't Fluent
responsible for generating the XML that is then passed to NHibernate?
Can't Fluent, before passing the XML on to NHibernate, perform pre-checks
to see if there's anything missing or odd about the object model?
That would probably be a lot easier than trying to parse the XML and
re-throwing the exceptions from NHibernate, although having the NHibernate
exception as an inner exception would of course make debugging a bit
richer. But since NHibernate's exceptions are so extremely sparse in the
information it provides and often just bubbles exceptions thrown by
underlying failure like "KeyNotFoundException", it's not that valuable to
pass on to the consumer, really.
Thus, throwing before NHibernate even sees the XML would make it easier to
spot configuration errors and such, imho.
-Asbjørn
On Mon, 13 Jul 2009 12:02:22 +0200, James Gregory
<jagreg...@gmail.com> wrote:
> The problem is NH really only throws one or two exceptions, just with
> varying messages. For example you get a MappingException if there's *
> anything* wrong with your mapping, and you have to parse the XML to