I currently have this class that another programmer in my team coded:
public static class SoapExecuter
{
private static readonly ILog logger;
public static Exception ExecuterException { get; private set; }
public static bool IsSoapException
{
get
{
if (ExecuterException == null)
return false;
return ExecuterException.GetType() == typeof(SoapException);
}
}
public static bool Execute(Action action)
{
ExecuterException = null;
bool passed = false;
try
{
action();
passed = true;
}
catch (SoapException se)
{
ExecuterException = se;
logger.log(se);
}
catch (Exception ex)
{
ExecuterException = ex;
logger.log(ex);
}
return passed;
}
}
This is not very idiomatic and I would like to change it to something that happens within the try...catch clause.
Is there a way to not violate DRY and still stay within the idioms the language offers?
Of course I can inherit from the SoapException and log it but I'll have to catch a SoapException and create a new exception object that wraps it and then throw it only to be silenced one level above.
Any idea guys?