Home All Groups Group Topic Archive Search About

Can't throw exception in calling class.

Author
30 Aug 2006 3:09 PM
benjamin.soulier
Hello all,

I got a problem using Exceptions in Debug mode in Visual Studio :
I got an Exception on a classe like :

catch Exception(e)
{
        DoSomething();
        throw e;
}

Running in debug mode when getting this exception works fine, but
trying to continue running code intercepting this exception in calling
classes doesn't work ; it's coming coming back over and over again on
this exception (no way to intercept it upper class methods).

Do you have any clue ?

Thanks everyone

Author
31 Aug 2006 2:00 AM
Jim Wooley
> I got a problem using Exceptions in Debug mode in Visual Studio : I
> got an Exception on a classe like :
>
> catch Exception(e)
> {
> DoSomething();
> throw e;
> }
> Running in debug mode when getting this exception works fine, but
> trying to continue running code intercepting this exception in calling
> classes doesn't work ; it's coming coming back over and over again on
> this exception (no way to intercept it upper class methods).

Typically you would wrap the exception in a custom exception and throw the
new wrapped version as follows:

catch Exception(e)
{
  DoSomething();
  throw new MyCustomInheritedException(e);
}

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

AddThis Social Bookmark Button