Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Exceptions should be handled by the layer that concerns it. Because an exception is checked does not mean you can handle it or that you must handle it at every layer of your app. And it is at this point you may want to turn them into runtime exception. So you have exceptions you can ignore (log them), exceptions that you can't recover from and exceptions you can recover. The problem is the same exception type, for example SQLException, can enter in more than one category. IOException would also be another example. Programming errors that cannot be recovered should be runtime exceptions and should be caught close to the container for logging purpose or to have your app to fail "gently". Accessing an invalid index in a jdbc PreparedStatement is a programming error. Having connection problem is not. So at the data layer, you manage to make the distinction, then convert your unrecoverable exception into a runtime exception and throw it. And sometimes it does not mean that retrying to connect will work. Business methods should thake care of bussiness related exception only, that is why you don't handle NullPointerExceptions or ArrayIndexOutOfBoundsException everywhere in your code and you don't have to put them in your method signature. Same logic applies to a data source agnostic business method calculating the average salary of employees of dept., it should not throw SQLExceptions but should throw things such as InvalidDeptException if the user supplies a wrong dept. code. Throws declarations is also self documenting the code, if you throw your own runtime exceptions instead, be sure to document properly. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload