License Public Domain
Lines 20
Keywords
beta (3) catch (3) debug (6) try (3)
Included in this Library
Permissions
Group Owner: .Net
Viewable by Everyone
Editable by Spencer Ruport and ".Net" Group Owners
Hide
Need a quick chart or graph for your blog? Try our reStructured Text renderer. Join Siafoo Now or Learn More

Try-Catch-Beta Atom Feed 2

In Brief Try catch blocks are an important part of any application (provided the language supports them) but they can make debugging in a beta environment difficult. I use the following design method to set up proper error handling while still being able to take advantage of the Visual Studio debugger.... more
# 's
 1public void MyFailProneFunction()
2{
3 if(!BETA)
4 {
5 try
6 {
7 MyFailProneFunction_Base();
8 }
9 catch(Exception ex)
10 {
11 // ... Exception handling code ...
12 }
13 }
14 else
15 MyFailProneFunction_Base();
16}
17
18public void MyFailProneFunction_Base()
19{
20 // ... Functionality Code ...
21}

Try catch blocks are an important part of any application (provided the language supports them) but they can make debugging in a beta environment difficult. I use the following design method to set up proper error handling while still being able to take advantage of the Visual Studio debugger.

This snippet assumes there is a global boolean value BETA defined elsewhere in the code to specify whether the application is in a production or beta environment.

By leaving the function call outside of the try catch block when in beta mode the debugger will function normally. Visual Studio can break on all exceptions if set to but this design allows you to create several different beta booleans to specify precisely which portion of code you want exceptions to break on.