Re: [問題] 程式的例外
嗯。其實我也不太明白合理的選擇方式。
不過有些 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
→
04/16 10:01, , 1F
04/16 10:01, 1F
討論串 (同標題文章)