I have code sample:
public abstract class BaseClass{
try
{
return Convert(value);
}
catch(Exception ex)
{
logger.LogError(ex);
throw new Exeption("Can't convert to type {0}", type);
}
}
How to refactor this one. I can't remove throw because method must return type. But new exception will hide original one.
To solve your issue you should use the keyword "throw" alone.
try
{
return Convert(value);
}
catch(Exception ex)
{
logger.LogError(ex);
throw;
}
In that way the same exception as the one you received will be thrown again and you will keep all the stack trace.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments