Jader Dias
Jader Dias

Reputation: 90465

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?

Upvotes: 5

Views: 126

Answers (2)

Mitch Wheat
Mitch Wheat

Reputation: 300489

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

enter image description here

Upvotes: 6

Ignacio Soler Garcia
Ignacio Soler Garcia

Reputation: 21855

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.

Upvotes: 2

Related Questions