Is there a better way to get visual studio to ignore try / catch in debug mode

I want the designer to catch an error when I debug, and I want the user to see my welcome message if an error occurs for them. I know that I can accomplish this with the following:

#If Debug=False Then

Try

#End If

'some code here

#If Debug=False Then

Catch ex as exception

    Messagebox.Show("Errors suck")

End Try

#End If

I don't want to write all #statements and make them clutter up my code. It seems like this should be a common need, and there should be a better way. Does anyone know a better way?

+5
source share
5 answers

VS.NET , , , ( ).

Debug | ... (Ctl-Alt-E ). , "" .

( CLR, CLR )

+15

, , . . catch. - .

Try
... 
Catch ex As Exception
  DebugLog(ex)
  Throw
End Try

<Condition("DEBUG)> _
Public Sub DebugLog(ByVal ex As Exception) 
  Messagebox.Show("errors suck")
End Sub
+3

catch Try..Catch , stacktrace , - , Windows.

Catch Try..Catch, , .

0

, , . - ? , , , - . , ... , - .

, , ...

0

:

:

Try ' : Catch: End Try
  doSomething
  andSomeMore
  etcEtc
' Try
Catch ex As Exception
  handleException
End Try

, :

Try : Catch : End Try
  doSomething
  andSomeMore
  etcEtc
Try
Catch ex As Exception
  handleException
End Try
0

All Articles