<div dir="ltr">On Fri, Apr 19, 2013 at 10:00 AM, Cantor, Scott <span dir="ltr">&lt;<a href="mailto:cantor.2@osu.edu" target="_blank">cantor.2@osu.edu</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 4/19/13 9:24 AM, &quot;Marvin S. Addison&quot; &lt;<a href="mailto:marvin.addison@gmail.com">marvin.addison@gmail.com</a>&gt; wrote:<br>


<br>
&gt;I can imagine there may be cases where the post routine might want to<br>
&gt;know an error occurred. If you don&#39;t care about passing in exception<br>
&gt;context to the post method, the simplest solution:<br>
&gt;<br>
&gt;try {<br>
&gt;   doExecute(...);<br>
&gt;} finally {<br>
&gt;   try {<br>
&gt;     doPostExecute(...);<br>
&gt;   } catch (Exception e);<br>
&gt;     log.error(&quot;doPostExecute failed&quot;, e);<br>
&gt;   }<br>
&gt;}<br>
<br>
</div>I started there, but I&#39;m not comfortable swallowing a runtime error<br>
altogether unless something else is being thrown. Since the post method is<br>
not even supposed to throw, the fact that it does is something I don&#39;t<br>
really want to hide. All of this occurs inside of an overarching execute()<br>
method. If that throws, I want it to be visible.<br>
<br>
The idea of passing the error into the post method is a good one, I&#39;ve<br>
done that sort of thing before.</blockquote><div><br></div><div style>You&#39;ll have to choose which exception you want to propagate out if both doExecute and doPostExecute throw:</div><div style><br></div><div style>Exception executeEx = null;</div>

<span style="color:rgb(80,0,80)">try {</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">   doExecute(...);</span></div><div class="gmail_quote">} catch (Exception e) {</div><div class="gmail_quote">  executeEx = e;<br>

<span style="color:rgb(80,0,80)">} finally {</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">  try {</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">    doPostExecute(...);</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">  } catch (Exception e);</span></div><div class="gmail_quote">    if (executeEx != null) {<br style="color:rgb(80,0,80)"></div><div class="gmail_quote"><span style="color:rgb(80,0,80)">      log.error(&quot;doPostExecute failed&quot;, e);</span></div>

<div class="gmail_quote">      throw executeEx;</div><div class="gmail_quote">    } else {</div><div class="gmail_quote">      throw e;</div><div class="gmail_quote">    }<br><span style="color:rgb(80,0,80)">  }</span><br style="color:rgb(80,0,80)">

<font color="#500050">}</font></div><div class="gmail_quote"><font color="#500050"><br></font></div><div class="gmail_quote" style><font color="#500050">Or something like this...</font></div><div class="gmail_quote" style>

<font color="#500050"><br></font></div><div class="gmail_quote" style><font color="#500050">--Daniel Fisher</font></div><div class="gmail_quote" style><font color="#500050"><br></font></div></div></div>