<div dir="ltr">On Fri, Apr 19, 2013 at 10:00 AM, Cantor, Scott <span dir="ltr"><<a href="mailto:cantor.2@osu.edu" target="_blank">cantor.2@osu.edu</a>></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, "Marvin S. Addison" <<a href="mailto:marvin.addison@gmail.com">marvin.addison@gmail.com</a>> wrote:<br>
<br>
>I can imagine there may be cases where the post routine might want to<br>
>know an error occurred. If you don't care about passing in exception<br>
>context to the post method, the simplest solution:<br>
><br>
>try {<br>
> doExecute(...);<br>
>} finally {<br>
> try {<br>
> doPostExecute(...);<br>
> } catch (Exception e);<br>
> log.error("doPostExecute failed", e);<br>
> }<br>
>}<br>
<br>
</div>I started there, but I'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'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've<br>
done that sort of thing before.</blockquote><div><br></div><div style>You'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("doPostExecute failed", 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>