License Public Domain
Lines 14
Keywords
beta (3) catch (3) debug (6) try (3)
Included in this Library
Permissions
Group Owner: .Net
Viewable by Everyone
Editable by Spencer Ruport
Hide
Free your code from a slow death on your hard drive Join Siafoo Now or Learn More

Try-Catch-Beta Atom Feed 0

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 Sub MyFailProneSub()
2 If Not BETA Then
3 Try
4 MyFailProneFunction_Base()
5 Catch ex as Exception
6 ' ... Exception handling code ...
7 End Try
8 Else
9 MyFailProneFunction_Base()
10 End If
11End Sub
12
13Public Sub MyFailProneSub_Base()
14 ' ... Functionality Code ...
15End Sub

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.