473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get to specific Exception

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
2 1030
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
Thanks, this works!

Apr 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paw Pedersen | last post by:
When you are "working" on a specific node from a XmlDocument instance, is it possible to get the full xpath to this node? Regards Paw
3
by: needin4mation | last post by:
I'm writing c# asp.net. I have a dataset loading when the page loads and it has an itemdatabound event. When there is an error in the itemdatabound event I get the catch in the calling...
0
by: Antoine | last post by:
I am Debugging an asp.net that errors in one location, I have been reading all about tracing and pdb and such but still not too clear on the BEST and SIMPLEST way to debug to an approximate but...
2
by: UJ | last post by:
I'm getting a dataset back from a web service and I want to verify that the table I want exists before trying to access it (which will cause an exception.) Is there an easy way to check for a...
4
by: David Hirschfield | last post by:
I know this should be obvious, but how does one raise a specific type of OSError? When I attempt to perform a file operation on a non-existent file, I get an OSError: , but what if I want to raise...
5
by: cj | last post by:
When I run myMAPIMessage.Send(True) if the user cancels the resulting email it causes an exception. How do I trap this particular exception and say that's ok? try myMAPIMessage.Send(True)...
0
by: Reny | last post by:
Can any one give me a clue on how to handle OleDB Specific exception .like Primary key violation I want to catch specific exception and inform the user in a friendly way that this is the error...
3
by: joseph | last post by:
Hi, I have managed to use the try{} catch{(Exception e)} to catch all exceptions that is happens in the application. My application is an Active Directory Interface and need to report all...
4
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.