Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why does <code>RunSearch</code> not rethrow the exception after logging the problem?</p> <p>If you don't want to call <code>SaveMessages()</code> if <code>RunSearch()</code> fails then don't code it that way.</p> <p>My general thought is that each method's interface is specifying a "protocol". It must state its behaviour in the event of problems. Approaches include:</p> <ol> <li>If I get an error I will terminate the process. This is pretty extreme, limits the reusability of your method.</li> <li>I will return a count or status code or somesuch. It's up to you to decide whether to check that and whether any particular status code means it's safe to call some other method. I prefer not to rely on the client to remember to check status codes.</li> <li>If I fail I will leave things so that subsequent processing will be sane. For example, if my job is to create a linked list then in the event of errors I will not leave a dangling pointer or an initialized list. You may get an empty list, but at least well formed subsequent processing will work. This tends to imply some degree of agreement (ie. coupling) with the other methods. This is often the nicest approach, especially when coupled with good logging of the problems.</li> <li>I will throw an exception if I couldn't do the work. The exception will indicate whether there's some chance of things working later if you call be again (I use TransientException and InvalidRequestException quite a lot). Exceptions are useful because the client cannot (for Java checked exceptions) accidentally ignore them. When dealing with problems such as "could not open database" this seems reasonable. We really do not want folks mistaking "couldn't even get to the database" with "this person has no criminal record".</li> </ol>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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