作者qrtt1 (有些事,有时候。。。)
看板java
标题Re: [问题] 程式的例外
时间Tue Apr 16 09:59:08 2013
嗯。其实我也不太明白合理的选择方式。
不过有些 library 设计者会写下他们的 Exception 管理策略
这是一个参考的方向,例如 AWS SDK
http://aws.amazon.com/articles/Amazon-S3/3604
<%
Exception Handling
Understanding how and when the AWS SDK for Java throws exceptions
is important in order to build high quality applications
using the SDK. The following sections describe the different
cases of exceptions that are thrown by the SDK and how to
handle them appropriately.
Why Unchecked Exceptions?
The AWS Java SDK uses runtime (or unchecked) exceptions
instead of checked exceptions for a few reasons:
* To allow developers fine grained control over the errors
they want to handle without forcing them to handle exceptional
cases they aren't concerned about (and making their code overly
verbose)
* To prevent scalability issues inherent with checked exceptions
in large applications
In general, checked exceptions work well on small scales,
but can become troublesome as applications grow and
become more complex.
For more information on the ongoing discussion
in the Java community around the use of checked and unchecked
exceptions, see the following references:
http://www.artima.com/intv/handcuffs2.html
http://www.mindview.net/Etc/Discussions/CheckedExceptions
http://radio.weblogs.com/0122027/stories/2003/04/01/
JavasCheckedExceptionsWereAMistake.html
%>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.130.128.164
1F:→ swpoker:就跟我说的一样阿~通通拿去做RuntimeException就好啦 04/16 10:01