By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

Get to specific Exception

P: n/a
Hi,

I have the following code:

try
{

if (isBadData == true)
{
// Throw exception to get to Exception 1
}
else
{

DistributionRow lRow =
this.Connection.ExtractData( DistributionID );

textMessage.Text = "Good data";

this.PlaySound(this.MainForm.GoodData);
}
}
catch (Exception) // Exception 1
{
textMessage.Text = "Bad data";
this.PlaySound(this.MainForm.BadData);
}
When isBadData == true, I'll need to get to "Exception 1" to output
"Bad data", etc. Anyone can advise me on how to throw the exception
inside the if (isBadData == true) block?

Thanks!

Apr 26 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
throw new Exception();

"Curious" wrote:
Hi,

I have the following code:

try
{

if (isBadData == true)
{
// Throw exception to get to Exception 1
}
else
{

DistributionRow lRow =
this.Connection.ExtractData( DistributionID );

textMessage.Text = "Good data";

this.PlaySound(this.MainForm.GoodData);
}
}
catch (Exception) // Exception 1
{
textMessage.Text = "Bad data";
this.PlaySound(this.MainForm.BadData);
}
When isBadData == true, I'll need to get to "Exception 1" to output
"Bad data", etc. Anyone can advise me on how to throw the exception
inside the if (isBadData == true) block?

Thanks!

Apr 26 '07 #2

P: n/a
Thanks, this works!

Apr 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.