Catching Exception by Source
What I am trying to accomplish is catch an exception by the actual method that's being called. This is what I got so far, but what I found out is its only catching the exception by the namespace.
public static void ExceptionHandler(Exception ex)
{
if (ex.Source.Contains("Service"))
{
Console.WriteLine("***Warning: " + ex.Message + " Source: " + ex.Source);
}
if (ex.Source.Contains("SetServiceController"))
{
Console.WriteLine("***Error: " + ex.Message + " Source: " + ex.Source);
}
Console.WriteLine("Error: " + ex.Message + " Source: " + ex.Source);
}