drizzt
drizzt

Reputation: 2886

Catch Exception only in release

HI, I have one global generic exception handler(catch ex as Exception) for all unhandled exceptions from application. But in debug mode(app runs from VS) I don`t want that exceptions go to this global handler. Better for me is when VS stops app on place when exception occurs.

How can I do this, or is there some better approach for this?

thanks

Upvotes: 2

Views: 176

Answers (2)

drizzt
drizzt

Reputation: 2886

finally I found solution:

    Try
    ......
#If DEBUG Then
    Catch ex As Exception When False
#Else
    Catch ex As Exception 
#End If
    ......
    End Try

ps: thanks to JYelton for hint.

edit:simplified solution

Upvotes: 3

JYelton
JYelton

Reputation: 36522

You could use a preprocessor directive (this example is C#):

#if DEBUG
// omit exception handling (or use a different one)
#else
// exception handling event subscriber here
#endif

Upvotes: 2

Related Questions