Error checking V.S. Exception

来源:互联网 发布:搜狗浏览器 mac 编辑:程序博客网 时间:2024/05/29 05:58
1)Error checking

if (bad_condition) then
begin
    ShowMsg("bad");
    return ERROR_CODE_1;
end;

2)raise exception
if (bad_condition) then
    raise Exception.Create("bad")

comparision:
1)communicate with UI directly, the program is not flexiable
2)return exception to caller, then choose to handle or show to user, it's more flexiable
原创粉丝点击