Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>Questions to ask yourself:</h3> <ol> <li>Who will be catching it? If no one, then you don't really need a custom exception. </li> <li>Where will you be throwing it? Is there enough context readily available, or will you need to catch and re-throw several times before the exception is useful to the final catcher?</li> <li>Why are you throwing it? Because you caught an exception and need to attach additional information? Because you encountered an unrecoverable error in some data, and need to communicate the specifics back to client code? Because you like <code>throw</code>ing things?</li> <li>What is the exception? Not what caused it but what is it <strong>from the perspective of the catcher</strong>? Something they can fix and retry? Something they should <em>never</em> retry? Something they should notify the user about? Something they should attach context information to and then re-throw? <em>What</em> determines the information you'll need to pass along, if any...</li> </ol> <h3>Precepts:</h3> <ol> <li>Do not waste time on custom exceptions that will never be caught. </li> <li>Do not "double up" exceptions: each custom exception type should have a well-defined case where it can and should be caught; exceptions that don't match should be broken out into their own custom types (rather than, say, forcing the catcher to build conditional logic into a single <code>catch()</code> clause).</li> <li>Unless you have a <em>good</em> reason not to, always allow attaching an inner exception / data from a previously-caught exception. Losing context is rarely helpful.</li> </ol>
    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. 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