views:

36

answers:

2

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

+2  A: 

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
JYelton
good idea but I don`t want to do this:#if DEBUG ...a lot of code...#else try ...a lot of code... catch ex as Exception end try#endif,because of repeating code. Are there some other approaches?
Cicik
You could set some variable inside of the `#if DEBUG` and use that to further differentiate between what to do (or not) in debug mode. It sounds like you want to handle exceptions differently in multiple places based on this comment, rather than just a global handler.
JYelton
+3  A: 

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

Cicik