473,408 Members | 2,477 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,408 software developers and data experts.

Try .. Catch with no Exception needed.

RP
In certain code blocks I don't want to do anything when an error is
raised. I simply want that application must remain stable instead of
crash. For the following code, is there a way to ignore declaration of
Exception ex:

try
{
//do somthing
}
catch (Exception ex)
{ //do nothing };

Since I am not using ex, it raises too many warnings.
Jan 24 '08 #1
4 5533
try

{

}

finally

{

}

"RP" <rp*********@gmail.comwrote in message
news:e7**********************************@e32g2000 prn.googlegroups.com...
In certain code blocks I don't want to do anything when an error is
raised. I simply want that application must remain stable instead of
crash. For the following code, is there a way to ignore declaration of
Exception ex:

try
{
//do somthing
}
catch (Exception ex)
{ //do nothing };

Since I am not using ex, it raises too many warnings.

Jan 24 '08 #2
PO
Uzytkownik "RP" <rp*********@gmail.comnapisal w wiadomosci
news:e7**********************************@e32g2000 prn.googlegroups.com...
In certain code blocks I don't want to do anything when an error is
raised. I simply want that application must remain stable instead of
crash. For the following code, is there a way to ignore declaration of
Exception ex:

try
{
//do somthing
}
catch (Exception ex)
{ //do nothing };

Since I am not using ex, it raises too many warnings.
You can use :

try{
}
catch(Exception){
}

no warnings ;-)

Jan 24 '08 #3
On 24 Jan., 15:08, "PO" <crac2...@interia.plwrote:
Uzytkownik "RP" <rpk.gene...@gmail.comnapisal w wiadomoscinews:e7********************************* *@e32g2000prn.googlegroups.com...
In certain code blocks I don't want to do anything when an error is
raised. I simply want that application must remain stable instead of
crash. For the following code, is there a way to ignore declaration of
Exception ex:
try
{
* //do somthing
}
catch (Exception ex)
{ *//do nothing };
Since I am not using ex, it raises too many warnings.

You can use :

try{

}
catch(Exception){
}

no warnings ;-)
If you don't care about the type of exception you catch you can even
write:
try
{
}
catch
{
}
Jan 24 '08 #4
It should be noted that if you catch an Exception (or just have a catch
statement) that your application won't necessarily be "stable". In catching
all exceptions (instead of just ones you know are going to be thrown) you
are corrupting your application state to some degree, and if you aren't
fastidious about defining the boundaries of your application, you will have
unexpected errors because of exceptions that were thrown and ignored in
other areas.

In other words, be very careful about proceeding in this manner. There
are reasons that exceptions are thrown, and you should ignore them at your
own peril.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"RP" <rp*********@gmail.comwrote in message
news:e7**********************************@e32g2000 prn.googlegroups.com...
In certain code blocks I don't want to do anything when an error is
raised. I simply want that application must remain stable instead of
crash. For the following code, is there a way to ignore declaration of
Exception ex:

try
{
//do somthing
}
catch (Exception ex)
{ //do nothing };

Since I am not using ex, it raises too many warnings.

Jan 24 '08 #5

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

Similar topics

5
by: David | last post by:
I am having a bit of a problem with catching an exception within a thread. Here is the scenario: I have a Windows Form. I create a new thread. This new thread calls a method in another DLL...
3
by: Pete Davis | last post by:
I've got the following code: try { reader = new StreamReader(configFile); XmlSerializer serializer = new XmlSerializer(typeof(ServerConfig)); config = (ServerConfig)...
3
by: Sunny | last post by:
Hi, I have created a StringBuilder (Log) in my application that appends all the errors and exceptions in my application. I have included Catch blocks at each sensitive location in my functions. I...
10
by: mttc | last post by:
I read articles that suggest preventing delete by throwing Exception from RowDeleting Event. I not understand where I can catch this Error?
7
by: Mr Flibble | last post by:
Are try { //something } catch { // }
17
by: cashdeskmac | last post by:
Nice and simple one for you all... Is there a time to use Catch(Exception) rather than creating an instance of the Exception, as in Catch(Exception ex)?
7
by: Daimler | last post by:
i am using visual c++ 2005 clr window form with try and catch a serial port readline. the codes are as follows: - try{ Form1::textBox1->Text = Form1::serialPort1->ReadLine();
1
by: bob | last post by:
I have a console application and a timer inside. The timer will throw an Exception while event Elapsed. but i cannot catch this Excepion, How can I catch the Exception?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.