This is the skeleton of the code I have:
if(CheckForSomething())
{
try
{
//do something
}
catch (UnauthorizedAccessException ex)
{
LogException(ex, item.server);
}
catch (Exception ex)
{
LogException(ex, item.server);
}
}
else
{
string error = "Some error";
//want to call LogException with error as argument
}
private static void LogException(Exception ex)
{
//write ex to one log file
// write ex.message to another log file
}
How can I call LogException method from the else block? I tried casting string as exception and creating an exception.