Hi Luke,

Thanks for your answer, this a little bit accomplishes what I was aiming
for. I have to touch each try/catch block though.

What I conclude about this is that is better for my future application to
not have try/catch blocks any at all. Just have the main one in the
bootstrap and let it do the job.

Am I right or not catching individual exceptions is not a good approach?

Thanks!



Luke Richards wrote:
> 
> 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!
>>>>
>>>>       
>>>     
>>
>>   
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Catching-catched-exceptions-tp19874696p19876374.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to