Method2() often throws an exception itself which therefore suppresses (hides) the exception thrown in Method1(). The exception of Method1() however is much more important than the exception thrown by Method2(). So I want to make sure that the first exception thrown in Method1() gets through to the user.
Well, it looks like I have to live with passing the exception manually on to Method2(). Thanks anyway, Jan > -----Original Message----- > From: John Lam [mailto:[EMAIL PROTECTED]] > Sent: Friday, 31 May 2002 2:34 PM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Detect Exception Handler > > > I'm pretty sure that I can implement this kind of behavior > using my AOP > engine and an intra-method join-point (don't know what to call it, > perhaps catch?) I can supply the context information in the call to > Method2(), and IsExecutingAsExceptionHandler() would simply > have to read > the context information. > > More importantly: why would you want to do this? > > -John > http://www.iunknown.com > > > -----Original Message----- > From: Jan Strube [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 30, 2002 8:31 PM > To: [EMAIL PROTECTED] > Subject: [ADVANCED-DOTNET] Detect Exception Handler > > I am wondering if it is possible to detect if some code executes as an > Exception handler. What I am after is the implementation of > IsExecutingAsExceptionHandler() in the following sample: > > void Method1() > { > Method2(); > try > { > throw new Exception(); > } > catch > { > Method2(); > } > } > > void Method2() > { > if (IsExecutingAsExceptionHandler()) > MessageBox.Show("Executes as exception handler"); > else > MessageBox.Show("Normal execution"); > } > > I am aware that I could pass on the exception object to Method2, but I > am looking for a way to avoid this. > > Thanks, > Jan Strube > > You can read messages from the Advanced DOTNET archive, > unsubscribe from > Advanced DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. > > You can read messages from the Advanced DOTNET archive, > unsubscribe from Advanced DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. > You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
