Visual Studio - suppress certain "Exception thrown" messages
c#, debugging, exception, visual-studio
Solution
To disable the Exception messages:
(1)Like your previous reply, you could disable it in the Output windows.
(2)You could also disable it under TOOLS->Options->Debugging->Output Window.
(3)Or you could just throw the Exception using the Exception Settings under Debug menu->Windows->Exception Settings.
I don't find other workaround to disable it unless you really resolve/handle the Exceptions in your code. I test it using the VS2015 version.
No other good suggestion, but I help you submit a feature here: https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/16752127-visual-studio-suppress-certain-exception-thrown-me
You could vote it.
Problem
Can you hide "Exception thrown" messages in output for certain methods (certain code areas)? I use HttpWebRequest for server communication. I periodically check if the server is available (a few times every second). When a server is not reachable HttpWebRequest throws an exception. I catch it and set GUI elements enabled to false. The problem is when the server is unreachable, output window gets cluttered up with "Exception thrown" messages. I know you can right-click output window and uncheck "Exception Messages". But I am not only one working on the project and there might be someone who wants to see some other exception messages (in their part of the project). Example of what I need: ``` // Keep showing "Exception thrown" message in this method. static void Foo() { try { throw new NotImplementedException(); } catch (NotImplementedException ex) { // Process exception } } // Suppress "Exception thrown" message when it is thown in this method. static void FooSuppress() { try { throw new ArgumentException(); } catch (ArgumentException ex) { // Process exception } } static void Main(string[] args) { Foo(); FooSuppress(); } ``` Current output: ``` Exception thrown: 'System.NotImplementedException' in ExceptionTest.dll Exception thrown: 'System.ArgumentException' in ExceptionTest.dll ``` Desired output: ``` Exception thrown: 'System.NotImplementedException' in ExceptionTest.dll ``` Edit: Enabling Just my code in Tools/Options/Debugging might help. We used Npgsql to access PostgreSQL database and some calls had timeout. Everytime call timeouted "Exception thrown" was written to output window (and there were a lot). Just my code prevents that.