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");
}