try-catch
如下编码一个块是一个好的设计实践吗?即throw
在 try 块中使用 a ,然后在 catch 块中捕获它。
try
{
if (someCondition){
throw new Exception("Go the the associated catch block!");
}
}
catch(Exception ex)
{
logError("I was thrown in the try block above");
}