Exit Try/Catch to prevent code after from being run
Posted
by coffeeaddict
on Stack Overflow
See other posts from Stack Overflow
or by coffeeaddict
Published on 2010-04-30T21:52:04Z
Indexed on
2010/04/30
21:57 UTC
Read the original article
Hit count: 195
c#
I've got for example a try/catch in my method:
}
catch (OurCustomExceptionObject1 ex)
{
txtErrorMessage.InnerHtml = "test 1";
}
catch(OurCustomExceptionObject2 ex)
{
txtErrorMessage.InnerHtml = "test 2";
}
catch (OurCustomExceptionObject3 ex)
{
txtErrorMessage.InnerHtml = "test 3";
}
... rest of code here is being executed after the try/catch
I do not want the rest of code to run if any of the exceptions are caught. I'm handling the exceptions. I heard do not use Exit Try for some reason. Is that true, it's bad to do this? Is this the right way to halt execution of code thereafter the catch statement?
© Stack Overflow or respective owner