Link to home
Start Free TrialLog in
Avatar of shanemay
shanemayFlag for United States of America

asked on

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?
Avatar of guru_sami
guru_sami
Flag of United States of America image

Don't think so...because that is a runtime issue and not the compile-time.
If you are not catching (trapping) the error it should error out.
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.
Avatar of shanemay

ASKER

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.  
ASKER CERTIFIED SOLUTION
Avatar of 13598
13598
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your help.