Two practical ways of error/exception handling

本文探讨了两种有效的错误处理方法:一是通过状态返回由顶层调用者处理;二是抛出异常并由调用者捕获。同时强调了断言在错误处理机制中的重要性。

Better error/exception handling. 2 ways:
a) return status upwards the function calling chain and have the top calling function process the status;
b) not necessarily return the status but throw exception when something’s wrong, catch and process the exception in the top calling function or let the calling module catch it.
It’s better if we can combine these two methods effectively.

Instrumentation:
We should pay more attention on assert usage and make it a part of the error/exception handling mechanism.

转载于:https://www.cnblogs.com/taoxu0903/archive/2007/05/14/745282.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值