有些帖子询问这两者之间的区别是什么.
(为什么我还要提这个...)
但我的问题是不同的,我称之为"抛出前"在另一个错误的神像处理方法.
public class Program {
public static void Main(string[] args) {
try {
// something
} catch (Exception ex) {
HandleException(ex);
}
}
private static void HandleException(Exception ex) {
if (ex is ThreadAbortException) {
// ignore then,
return;
}
if (ex is ArgumentOutOfRangeException) {
// Log then,
throw ex;
}
if (ex is InvalidOperationException) {
// Show message then,
throw ex;
}
// and so on.
}
}
Run Code Online (Sandbox Code Playgroud)
如果try & catch
用于Main
,那么我会throw; …