throw statement inside a catch block continually caught be same catch block?

throw statement inside a catch block continually caught be same catch block?

Post by Tracy Bann » Sat, 03 Jan 2009 00:14:50


I am using VS2008 with C# to write a demo app. I have just begun to
add exception management.

I added a simple proof of concept method shown below where I catch an
exception and propogate it using throw.

When I run this in the IDE, with a break point set on the catch
statement and on the throw statement, I find that the throw statement
"appears"
to be caught by the same catch block. Note: The calling routine does
not have any retry logic.

The IDE stops on the throw statement and shows the exception handling
dialog box.


public void UpdateTeamMember(TeamMember teamMember)
{

try
{
//TODO: remove this testing
throw new Exception
("BusinessComponentTestException");

catch (Exception ex)
{
bool rethrow = ExceptionPolicy.HandleException(ex,
"BusinessComponentNotifyRethrow");
if (rethrow)
{
throw;
}

}

}


(BTW, I'm using EL3.1 and my exception handling policy returns
true)

I'm a little perplexed. I must have a visual studio IDE setting or
option incorrect?
 
 
 

throw statement inside a catch block continually caught be same catch block?

Post by Steve » Sat, 03 Jan 2009 01:21:08

Hi Tracey
It sounds like the throw in the catch block isnt being handled anywhere in
your code, so you may be getting an exception is unhandled message? If
thats the case then the calling method needs to handle the exception thrown
in your catch block.

Cheers
Steve

 
 
 

throw statement inside a catch block continually caught be same catch block?

Post by Family Tre » Sat, 03 Jan 2009 02:25:15


Look at the "Debug" menu, and select "Exceptions". I think there is an
option to stop on thrown exceptions there.

--
Mike
 
 
 

throw statement inside a catch block continually caught be same catch block?

Post by Tracy Bann » Sun, 04 Jan 2009 23:22:00


My "harness" does have try/catch handling but appears to be on a
different thread somehow. Here are more details: My application is a
WPF application using the Prism (composite guidance).

My app.xaml.cs (which is the entry point into the app) has an outer
try/catch for handling however, it was never reached. The app.xaml.cs
invokes a bootstrapper class (bootstrapper.run).

I added an UnhandledException event handler in the app.xaml.cs and
that allowed me to catch the exception.

The bootstrapper sets up the entire application, WPF views,
presenter, models etc. I'm certain that I will have more questions on
this as I continue working with it.

Thanks for pointing me in the right direction.