Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view exceptions when debugging?

I'm using NLog like this

try
{
    // ... some code
}
catch(AException ex)
{
    logger.ErrorException(ex.Message, ex);
}

But I want to see the exception when debugging. So I tried:

#if !DEBUG
    try
    {
#endif
        // ... some code
#if !DEBUG
    }
    catch(AException ex)
    {
        logger.ErrorException(ex.Message, ex);
    }
#endif

Is there a neater way of doing that?

like image 882
Jader Dias Avatar asked Mar 06 '12 13:03

Jader Dias


2 Answers

Turn on First Chance Exceptions: CTRL-ALT-E (tick the thrown column for CLR exceptions)

enter image description here

like image 130
Mitch Wheat Avatar answered Oct 13 '22 01:10

Mitch Wheat


Don't do it this way. It's better to turn on Exception notification on Debug->Exceptions. This way you will see exceptions when they are created even if they are handled latter on.

like image 37
Ignacio Soler Garcia Avatar answered Oct 13 '22 01:10

Ignacio Soler Garcia