Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Throw new ApplicationException
Message
From
07/09/2006 11:47:12
 
 
To
07/09/2006 11:24:50
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01151872
Message ID:
01151891
Views:
27
Hi Jerry,

I believe you're catching a different exception than you're Throwing. I.e. you're Throwing an ApplicationException, but you're Catching an ArgumentException.

Bill

>I am using VS .Net 2005 and I am trying to throw an ApplicationException() inside of my method and trap that error with a TRY/CATCH block. However, I can't get this to work. Below is my code.
>
>
>public void function1()
>{
>    try
>    {
>    	//This should trap error.
>        this.function2();
>    }
>    catch (ArgumentException ae)
>    {
>        MessageBox.Show("An error occurred! -> " + ae.Message);
>    }
>}
>
>public bool function2()
>{
>    string lc_value = "";
>    if (lc_value == "")
>    {
>        throw new ApplicationException("My Error occurred!");
>    }
>
>    //Continue normal operation.
>
>    return true;
>}
>
>
>I would expect that when the throw new ApplicationException() was triggered, that my CATCH block would gain control and display my custom error message. However, what actually happens is that a VS error dialog displays my custom message and my CATCH block is not called.
>
>How can I trigger a error and capture it with a TRY/CATCH block?
>
>Thanks,
>
>Jerry
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform