I always add a variable in my catch structure:
catch (Exception e)
{
// ...
}
Even when I don't use e in the catch block.
I do so because I don't know how to get the exception (and its detail) if I enter an "anonymous" catch while debugging.
catch { /* ...how to get the exception from here ?... */ }
If the exception is not used in the catch block I get a CS0168 warning: "variable e is unused"
I know how to globally disable CS0168 (or locally) but I'd rather not have to do so because it could hide useful messages too.
I'd rather not have to add fake code in the block to use the exception so that it does not raise the warning.
I'd rather not edit/remove the parameter accordingly to its (not) usage in the catch block just to remove the warning.
Ideally I want to know how to get the instance of the exception when debugging.