Visual Studio 2010 Code Settings

Is it possible to set visual studio to give a compile error or warning when you are not catching exceptions.  For example, If I try to open a connection to a SQL database and do not catch the SqlException that is possible when you invoke the open method, is it possible for Visual Studio to give me a warning or error?
shanemayAsked:
Who is Participating?
 
13598Connect With a Mentor Commented:
The closest in visual studio would be the Code Analysis tab. You can go through all the settings there and then run a code analysis.
0
 
guru_samiCommented:
Don't think so...because that is a runtime issue and not the compile-time.
0
 
13598Commented:
If you are not catching (trapping) the error it should error out.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
13598Commented:
Oh! Are you asking if you can easily set your compile warning configuration to warn you whenever a sql object/step that could error out does not have a try/catch statement to account for the possibility of an error? Then no, I don't believe so.
0
 
shanemayAuthor Commented:
That is correct, I use IntelliJ for Java development and it will warn you if you invoke a method that throws an error.  It might be because C# does not support checked exceptions. In Java, these are declared using the throws keyword, to specify that a method can throw a particular type of exception that must be handled by the calling code.  
0
 
shanemayAuthor Commented:
Thank you for your help.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.