Java异常处理: 一个男人和一个女人的故事

来源:互联网 发布:喜马拉雅听书软件下载 编辑:程序博客网 时间:2024/05/01 13:15

 1. If you can't handle an exception, don't catch it.

 

如果你不能好好对待她,不要骚扰她。

 

2. Catch an exception as close as possible to its source.

 

如果你想追求她,首先你要靠近她。

 

3. If you catch an exception, don't swallow it.

 

如果你已得到她,就要善待她。

 

4. Log an exception where you catch it, unless you plan to re-throw it.

 

如果你已得到她,就要好好了解她,除非你想抛弃她。

 

5. Never throw unchecked exceptions in your methods just because they clutter the method signature.

 

如果你已抛弃她,就要提醒别人继续追求她。

 

6. Preserve the stack trace when you re-throw the exception by wrapping the original exception in the new one.

 

如果你想抛弃一个全新的她,请尽量保留那个旧的她,以便别人还能够认出她。

 

原创粉丝点击