I'd like to be able to put a try/catch around SqlCommand.ExecuteReader
and the like, so that I can catch ADO exceptions and log the offending query with better information than is contained in the exception that gets thrown by NH. I've tried to get there in various ways, like overriding SqlClientDriver
to return my own version of SqlCommand
, but between the fact that the interface changed with NH5 to using DbCommand
rather than IDbCommand
(so I can't use a proxy) and the fact that SqlCommand
itself is sealed (so I can't use a subclass), I've been stymied.
To be clear: I don't want to simply translate the exception. I want all the information about the original query in hand wherever I catch it.
Thanks.