“扔”和“扔前”有什么區(qū)別嗎?有些帖子問(wèn)這兩者之間有什么區(qū)別。(我為什么要提這個(gè).)但是我的問(wèn)題在另一個(gè)錯(cuò)誤中是不同的,我稱之為“拋出前”。上帝般的處理方法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.
}}如果try & catch在Main,那我就用throw;重新拋出錯(cuò)誤。但是在上面簡(jiǎn)化的代碼中,所有的異常都會(huì)通過(guò)HandleException是嗎?throw ex;具有與調(diào)用相同的效果。throw當(dāng)被召喚入內(nèi)HandleException?
- 3 回答
- 0 關(guān)注
- 771 瀏覽
添加回答
舉報(bào)
0/150
提交
取消