Would appreciate any advice on this please?
Say I have created a .NET class library to log exceptions to a database (ErrorLoggingDLL).
I reference that DLL in another .NET Windows application.
I then write a method in the latter along the lines of : -
public void test()
{
try
{
DoSomething();
}
catch (Exception ex)
{
ErrorLoggingDLL.LogError(
ex)
}
}
What should my strategy be if the LogError method itself throws an exception? Should I just ignore it or replace the code above with....
public void test()
{
try
{
DoSomething();
}
catch (Exception ex)
{
try
{
ErrorLoggingDLL.LogError(
ex)
}
catch (Exception)
{
// what should I do here - because my ErrorLoggingDLL.LogError itself has thrown an error.
// should I a) not throw an error from the ErrorLoggingDLL.LogError method?
// b) throw it and handle it here (if so what do I do with the error)?
// c) throw it and handle it here by the deprecated practice of a catch block with no code in it?
}
}
}