I would like to have a method that gets the type of exception (i.e. the parameter passed must be a class that implements System.Exception).
What is the right way to do this?
Below I DO NOT want:
public void SetException(Exception e)
... which requires an exception instance. I want to pass an exception type likeInvalidProgramException
Edit: To clarify what I want to do, I want to be able to track how many times I saw exceptions for each type before. So I want to be able to do something like:
Dictionary<ExceptionTypeThing, int> ExceptionCounts;
public void ExceptionSeen(ExceptionTypeThing e)
{
ExceptionCounts[e]++;
}
ExceptionSeen(InvalidProgramException);
I do not want to pass an instance of the exception, but track it by the type of exception.
source
share