Hi,
The current NHibernate proxy interceptor (correctly) re-throws any errors to maintain the original exception type. Unfortunately, this is causing the exception stack trace to be lost. (mentioned in the code comments in the CastleLazyInitializer.cs)
current trunk code:
Code:
// Propagate the inner exception so that the proxy throws the same exception as
// the real object would (though of course the stack trace will be probably lost).
throw tie.InnerException;
I found a blog that mentioned a way of re-throwing the original error, while also keeping the original stack-trace:
http://dotnetjunkies.com/WebLog/chris.taylor/archive/2004/03/03/8353.aspx
I've also put together a potential patch that uses this code:
http://freespace.virgin.net/richard.brown0308/NHibernateExceptionStack.patch
Could someone take a look and see if they think this is worth fixing in NHibernate?
Thanks,
Richard