捕获异常并重新抛出异常时需要考虑哪些最佳实践?我想确保保留Exception对象InnerException和堆栈跟踪.以下代码块在处理此方式时是否存在差异?
try
{
//some code
}
catch (Exception ex)
{
throw ex;
}
Run Code Online (Sandbox Code Playgroud)
VS:
try
{
//some code
}
catch
{
throw;
}
Run Code Online (Sandbox Code Playgroud)