Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In general, you probably want to catch exceptions at the lowest possible level in your code. The closer they're handed relative to where the exception occurs, the better chance that you have to fix the problem that caused them.</p> <p><strong>If you <em>can't</em> take any corrective action at this level that has a hope of fixing the problem causing the exception, you <em>should not be handling it at all</em>.</strong> Just let the exception bubble up, and handle it globally like you want.</p> <p>That being said, if you've have <em>handled</em> the exception at a lower level, <strong>the only way you're going to be able to catch it at a higher level is if you <a href="http://msdn.microsoft.com/en-us/library/1ah5wsex(v=VS.100).aspx" rel="nofollow noreferrer"><em>rethrow</em> it</a></strong> from the <code>Catch</code> block at the lower level.<br>So, for example:</p> <pre><code>try { //your code } catch (SomeException e) { //take any relevant handling measures //rethrow the exception throw; } </code></pre> <p>Of course, this would technically mean that the exception is <em>unhandled</em> by this Try/Catch block at the lower level, but that's the only way you're going to have anything to catch at a higher level.</p> <p>For more information on rethrowing exceptions, see:</p> <ul> <li><a href="https://stackoverflow.com/questions/113565/why-re-throw-exceptions">Why Re-throw Exceptions?</a></li> <li><a href="http://weblogs.asp.net/fmarguerie/archive/2008/01/02/rethrowing-exceptions-and-preserving-the-full-call-stack-trace.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/fmarguerie/archive/2008/01/02/rethrowing-exceptions-and-preserving-the-full-call-stack-trace.aspx</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/xhcbs8fz.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/xhcbs8fz.aspx</a></li> </ul>
    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. 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.
    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