Oliver
Fri Aug 12 03:53:58 CDT 2005
Peter wrote:
> As I said in my original post, this a simplification of my problem, but my
> problem is much more complex, so I cannot do as you propose. The fact is,
> that all my logic handling the transaction is wrapped in a class, that is
> disposed using the using statement.
> But in my transactionhandling's Dispose implementation I want to determine
> if an exception was thrown
>
> using( TransactionHandling t = new TransactionHandling())
> {
> }
I understand, but I still think you should handle things differently :-)
For example, you could rethrow the exception to be caught outside your
transaction handling encapsulation. Or, if you absolutely want to break
out of the standard exception handling system, you could store away the
exception information in a catch block inside the class and evaluate
that information from the outside later on.
I thought I had at some point heard or read something about a way to
detect whether "there is currently an exception". But I was unable to
find whatever it was I had in mind there. The other thing is: Such a
mechanism could obviously only work if the exception was still "active"
at that point, in contrast to having been swallowed by a catch block
earlier on. So if the exception is really active at this point in your
code, what would keep you from simply catching it with a catch block?
What you are asking is, apparently, "how do I find out if an exception
was thrown before I got to the point where I'm now". The answer to that
will usually be yes, of course, because exceptions are thrown and caught
many times during the run of a .NET application (even though we all know
they shouldn't be used for flow control in the main execution path). Now
you are going to modify the question to say "I'm not interested in all
exceptions that might have been thrown before I got to the current
point, only in those that might have been thrown during the use of the
TransactionHandling class." So if that is your actual question, let me
ask again: Why don't you put an external try/catch around the use of the
TransactionHandling class and find out?
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619
http://www.sturmnet.org/blog