Put all the code you don't want to execute in the try block.

Larry


On Thu, Jul 30, 2009 at 4:06 PM, Bhaarat Sharma<bhaara...@gmail.com> wrote:
> Hi guys,
> I have a few questions on how to handle errors that are thrown when iBatis
> calls the Stored Procedures.
> Assuming i have the following code:
> results_list = getSqlMapClientTemplate().queryForList("spfile.getReport",
> parmMap);
> If i have the above code then when error occurs, we see it on the screen and
> it looks very ugly. Also, if the error occurs in above line then code after
> this line is not executed.  I wish to catch the error, put it in the log
> file and show user a page that something bad has happened.
> So I changed the above code to:
>         try {
>             results_list =
> getSqlMapClientTemplate().queryForList("spfile.getReport", parmMap);
>         }
>         catch (Exception e)
>         {
>             log.error(e.getMessage());
>         }
> this catches the error fine. BUT the problem is that, since I am catch the
> error, the code after the above call is also being executed.  Which I do not
> want.  If the error occurs in the above call then I don't want any further
> code to get executed.  We are implementing error handling at a later stage
> in the application.  It would have been better if the code written after the
> above call actually checked if something exists in results_list.  But that
> is not the case and it would be a pain to change all the code to suit this
> need now.
> How can I do this?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org

Reply via email to