It is not rare to see a verified version of the API; one of the most famous examples is IOExceptionc Closeable.close(). And often handling this exception really annoys me. An even more annoying example was in one of our projects. It consists of several components, and each component declares a specific checked exception. The problem (in my opinion) is that during development it was not known exactly what the exceptions would be. So, for example, the component is Configuratordeclared ConfiguratorExeption. When I asked why it is not easy to use excepted exceptions, they told me that we want our application to be reliable and not explode at runtime. But this seems like a weak argument because:
IOException
Closeable.close()
Configurator
ConfiguratorExeption
try-catch
I think this is a repeating picture. Nevertheless, checked exceptions are widely used in the API. What is the reason for this? Are there certain types of APIs that are more suitable for checked exceptions?
.
http://www.mindview.net/Etc/Discussions/CheckedExceptions
Runtime API.
Runtime
, Java API , Hibernate Runtime 3, Spring Framework Runtime .
, 1) , , 2) . - , API - , RuntimeException.
, , , , RuntimeException , ".
, , , , .
3 , , - .
, :
, , , - ( , ). Closable throw IOException, , .
, Java API , . , API- XML , ( XML-, , ...?), API- ( , , , , ...). .
, , " ", , .
, , , " , , , ", " " " RuntimeException Error...
, (, ConfiguratorException) , (, FileNotFound).
In general, I would caution against this, since this is most likely to be a fuzzy abstraction (no one should care about whether your configurator is trying to pull its data from the file system, database, via the network or something else)
If you use checked exceptions, then at least you will find out where and why your abstractions occur. IMHO, this is good.
Source: https://habr.com/ru/post/1757031/More articles:Large Matrix Inversion Methods - c ++Defining the primary keys of an object using context in Entity Framework 4.0 - reflection100% connreset with httperf? - load-testingStrange Java HashMap behavior - unable to find matching object - javaCan I extend the QPropertyAnimation refresh interval for ultra-smooth animation? - qtScroll only the page element, not the entire page - javascriptDelphi signature in exe files - delphiПользовательский контроль и приложение в одном проекте - c#How do you get / invite beta testers for your iPhone / iPad application? - iphoneShould I combine .css files with php to reduce HTTP requests? - javascriptAll Articles