关于使用Exceptions的几点小贴士

2018-10-08  本文已影响0人  泰兰德的加长香蕉

1. Exception handling is not supposed to replace a simple test. The moral is: Use exceptions for exceptional circumstances only.

2. Do not micromanage exceptions.

3. Make good use of the exception hierarchy.

4. Do not squelch exceptions.

5. When you detect an error, “tough love” works better than indulgence.

6. Propagating exceptions is not a sign of shame.

  Rules 5 and 6 can be summarized as “throw early, catch late.”

上一篇 下一篇

猜你喜欢

热点阅读