Reputation: 1339
Suppose I want throw exception only when I use the debug mode, I did:
try
{
throw new Exception("test)";
}
catch(Exception ex)
{
#if DEBUG
throw;
#else
Console.WriteLine("exception => " + ex.Message);
#endif
}
this works only on throw
, on the else condition I get:
The variable ex is declared but never used
Upvotes: 0
Views: 378
Reputation: 21722
#if DEBUG
catch(Exception)
{
throw;
}
#else
catch(Exception ex)
{
Console.WriteLine("exception => " + ex.Message);
}
#endif
Upvotes: 2