Exit Try/Catch to prevent code after from being run
- by coffeeaddict
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?