Hi

try {
   $result = $db->query(...);
   $db->update(...);
   // other code....
} catch(Exception $e) {
   // do something here
   throw $e
}

The important bit is that you are re-throwing the exception that you've caught. Alternatively you could throw a new exception but you'll loose the context data stored in the exception such as where the original error occurred. The error controller should by default be setup to catch the exception.

Hope that helps.

Luke

Mauricio Cuenca wrote:
Hello Marcelo,

It's basically something like this:

try {
        $result = $dbconn->query("SELECT * FROM TABLE");
} catch (Exception $e) {
        echo "Something is wrong...";
        exit();
}

I could modify the catch part and do some redirection or something similar,
but the code has many SQL calls like this. I don't want to change each one
manually.



Marcello Duarte wrote:
What code is in your catch statement?


Mauricio Cuenca wrote:
Hello,

I have an application that started small and now its big. The problem is
that each database transaction has a try/catch statement.

Now I want to capture all those exceptions and send them to the error
controller to display friendly error messages to users in the production
environment.

Is there a way to force the Error Controller to catch this already
catched exceptions without modifying each sql try/catch block in the
code?

Thanks!


Reply via email to