I don't know that this will be the best answer to your question, Lee,
but it may be of some use.  I remember reading a little quote
somewhere that basically said "Never test for an error that you don't
know how to handle."  My thinking is that you should only be setting
up exceptions when you already have a specific plan on how you want to
respond to them.

Please feel free to ignore my answer if someone else posts something
more useful to you.

On Feb 18, 10:20 am, "Lee Bolding" <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> Anybody have any advice or examples regarding intelligent handling of
> exceptions?
>
> I'm throwing and catching exceptions in both my action classes and in helper
> classes used by my actions, but now what?
>
> I don't want to just throw an sfException and show the user a Symfony error
> page, that doesn't help them - and I'd like to obfuscate to the user
> whatever technology I'm using if possible.
>
> Imagine I have the following :
>
> class MyException extends Exception{}
>
> class homepageActions extends sfActions {
>   public function executeIndex()
>   {
>     try
>     {
>       throw new MyException("testing");
>     }
>     catch (MyException $e)
>     {
>       echo "Caught my exception\n", $e;
>       //$this->alerts[] = array('message' => $e->getMessage(), 'code' =>
> $e->getCode());
>     }
>     catch (Exception $e)
>     {
>     echo "Caught Default Exception\n", $e;
>     }
>   }
>
> }
>
> I don't want to echo those back to the user, and I don't want them to go
> unnoticed either.
>
> Ideally I guess I'd do nothing with any thrown exceptions, but hoover them
> all up in a postExecute() method, but I don't think that's possible :-/
>
> Maybe using something similar to log_message (but available outside of debug
> environment)?
>
> Right now I have an $alerts array and have an alerts partial, which contains
> handling and display logic for each exception (which is mostly placing the
> error into an "alerts" div, with the appropriate message via I18N helper).
> This is what I've commented out above.
>
> Is there a cleaner way of doing this? And one that isn't so... clunky?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to