exception
2016-04-18 08:36:50 1 举报
AI智能生成
Exception,中文意为“异常”,是计算机编程中常见的一个概念。当程序运行过程中出现错误或意外情况时,系统会生成一个异常对象,并将控制权转移到相应的异常处理程序。异常处理程序通常用于捕获和处理异常,以避免程序崩溃或产生不可预料的结果。在Java、Python等编程语言中,异常处理是通过try-catch语句来实现的。通过合理地使用异常处理机制,可以提高程序的健壮性和稳定性。
作者其他创作
大纲/内容
1. Handle problems at the appropriate level. (Avoid catching exceptions unless you know what to do with them.)
2. Fix the problem and call the method that caused the exception again.
3. Patch things up and continue without retrying the method.
4. Calculate som alternative result instead of what the method was supposed to produce.
5. Do whatever you can in the current context and rethrow the same exception to a higher context.
6. Do whatever you can in the current context and throw a different exception to a higher context.
7. Terminate the program.
8. Simplify. (If your exception scheme makes things more complicated, then it is painful and annoying to use.
9. Make your library and program safer. (This is a short-term investment for debugging, and a long-term investment for application robustness.)
0 条评论
下一页