[Catalyst-dev] A suggestion(or question) about exception handling.

Matt S Trout dbix-class at trout.me.uk
Thu Jul 24 03:05:05 BST 2008


On Wed, Jul 23, 2008 at 11:59:22AM -0400, Kee Hinckley wrote:
> I use Error extensively in Catalyst, but I understand the problem he  
> raises.  Right now Catalyst traps errors itself Catalyst::execute().   

If you throw Error objects, Catalyst will trap them just like any other
exception, and stuff them in $c->error for you to process later.

I don't honestly see how keeping an array of errors yourself is any
different? You could use a SIGDIE to inflate them to an exception
object on the way past if that's what you want? (or a custom Action
class with its own execute() method that would run within the Catalyst
execute() eval cage)

> What Chae Lee probably wants (I know I do) is a way to insert an Error  
> handler that traps those errors, or at the very least, uses try/catch  
> so that what gets stored in $c->error are Error objects instead of  
> strings.  You can't fix this with a Plugin because you have no way of  
> knowing when in the process your plugin will be called.

What do you mean "when in the process" ? What hooks do you think you need
that aren't already there? Something like $c->run_action_with_eval that
has just the eval { ... } part so you can infalte an exception object?
More than that? Something completely different?

More importantly, can one of you -please- show me a sketch of before -and-
after code with this feature you're imagining in place? I still really
don't get what this feature would achieve for you, all I'm seeing is
"this is awful, look at how ugly this code is" but no explanation of what
would be prettier and how you'd like to be able to get there.

I'd really like to make sure whatever you're trying to achieve, we add
the hooks so you can make a plugin that achieves it - and preferably
so anybody using another exception system can write one that works for
them, too (for e.g. I'd tend to use Exception::Class rather than Error
since it's (a) Moose (b) not maintained by an asocial idiot who's currently
trying to fork the catalyst IRC community over his banning from irc.perl.org)

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst-dev mailing list