473,395 Members | 1,670 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,395 software developers and data experts.

Avoiding the warning of not using Exception variable in catch

I have a 3rd control that throws an exception if the syntax of a method call
is incorrect. I am passing dynamic strings to that method so it is
acceptable that the method will fail. I have my try...catch setup as

try{ ...}
catch(Control.StrangeException sEx){ }

I get a compiler warning that I am not using sEx. I don't want to do
anything if the method fails and I would like the warnings to go away... any
ideas?

thx

jack
Nov 16 '05 #1
4 1280
On Sat, 26 Feb 2005 22:33:35 -0700, "Jack Addington"
<ja********@shaw.ca> wrote:
I have a 3rd control that throws an exception if the syntax of a method call
is incorrect. I am passing dynamic strings to that method so it is
acceptable that the method will fail. I have my try...catch setup as

try{ ...}
catch(Control.StrangeException sEx){ }

I get a compiler warning that I am not using sEx. I don't want to do
anything if the method fails and I would like the warnings to go away... any
ideas?

thx

jack


the command line paramater would be /w:0

like:

C:> csc.exe myApp.cs /w:0


Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio
Nov 16 '05 #2
Jack Addington <ja********@shaw.ca> wrote:
I have a 3rd control that throws an exception if the syntax of a method call
is incorrect. I am passing dynamic strings to that method so it is
acceptable that the method will fail. I have my try...catch setup as

try{ ...}
catch(Control.StrangeException sEx){ }

I get a compiler warning that I am not using sEx. I don't want to do
anything if the method fails and I would like the warnings to go away... any
ideas?


Just don't include the variable:

catch (Control.StrangeException) { }

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
It would have been nice if the compiler allowed the same thing for
unused method parameters also. Like
int SomeFunc(int x, int);

Regards
Senthil

Nov 16 '05 #4
sadhu <se**********@wdevs.com> wrote:
It would have been nice if the compiler allowed the same thing for
unused method parameters also. Like
int SomeFunc(int x, int);


I think that's a much rarer situation, myself - and one which should
have very clear documentation to say that you *will* be ignoring the
parameter's value.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

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

Similar topics

7
by: ChrisB | last post by:
Hello: I notice that the following statements generate a "the variable 'e' is declared but never used" warning: try { Company.Fetch(CompanyID); } catch(RecordNotFoundException e)
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
2
by: bluebeta | last post by:
Hi I am using embedded visual C++ and new to it. I have problem when I want to use try/catch. my try/catch code is as below: try { m_oaItem.Add(pItem); SetModifiedFlag();
1
by: Cindy H | last post by:
Hi I used the code below to automatically open a pdf file when the user clicks on a menu option. It works great on local machine, but when I uploaded it to hosting site and then tried it, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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...

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.