Java错误处理应怎样理解
Java异常处理应怎样理解
以下是我对Java异常处理的理解,希望大家给点意见。
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.
如果你想抛弃一个全新的她,请尽量保留那个旧的她,以便别人还能够认出她。
肛汁恋茎速湿
13 years, 8 months ago