On Thu, 16 Sep 2004 11:15:52 +0200, Sebastian Riedel wrote
> Simon Flack:
>
> >I've just got back from work and it's been a long day so I might not be
able
> >to send more code tonight. I put some effort into the patch and code sample
I
> >sent yesterday so it would be helpful, before I send more code,
> >
> I was just missing some kind of comparison, with and without exceptions.
> But i wrote some tests on my own, and if done right it makes the
> code shorter, especially for really big applications.
>
> So i will accept your patch, thanks! :)
> Maybe it would be a good idea to handle exceptions for authenticate()
> and additional_data() too...
Thanks. Yes, I was thinking it would also be good to handle exceptions during
$r->view_object->process(). I see there's already some error handling there,
but it would be good to rationalise the error handling.
The question is, if $r->exception() is called for any untrapped model errors,
authenticate() and additional_data() errors and possibly more, how can you
tell from the exception handler what stage the processing got to? For example,
if an exception was raised during $r->view_object->process(), you'll have to
set $r->{output} and not rely on templating. But if it catches an exception
during $r->model_class->process(), you can try and set $r->template() and let
the view carry on as normal.
There's already an $r->init_done(). We could add similar accessors for some of
the other phases listed in Maypole::Workflow. Then a complex exception handler
could look like this:
sub exception {
my ($r, $error) = @_;
if (defined $r->view_done() && !$r->view_done()) {
# exception happened during 'view' phase
$r->{output} = '...';
} elsif (defined $r->model_done() && !$r->model_done()) {
# ... during 'model' phase
$r->template('error_template');
} else {
# ...
}
}
We probably shouldn't dive too far into this without thinking about it a bit
more. Being able to handle exceptions on the model processing is a good start.
--simonflk
_______________________________________________
maypole-dev mailing list
maypole-dev at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole-dev
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT