[Catalyst] Exceptions and templates and stuff.

Caroline Johnston johnston at biochemistry.ucl.ac.uk
Wed Nov 30 22:27:24 CET 2005


>
> Is your example code really in use?

yeah. At least, it seems to be working.

> I tend to show my form errors back on
> the same form page so the user can correct and move on.

Well, yeah. Actually that's what this does. I've got $c->template set to a
wrapper which checks whether the call was an XMLHttpRequest (not used AJAX
before, so not sure about this bit either. Is there a proper way of
checking if a request expects XML rather than a whole page?) and adds page
header and footer if required. The error bit actually sets
$stash->{content} rather than $c->stash->{template}, which is included in
the wrapper. Sorry, it seemed a bit long-winded to explain that, so I
changed it to {template}.

My forms have an AJAX submit button which is set to update a messages
div on the same page, so I either get a msg saying it worked, or an html
version of the dfv error messages so the user can fix their error.

I couldn't see how else to do things like checking if the password is
right or seeing if the user already exists in the DB without reloading the
whole page?

It seemed easier to do

  $c->form($dfv_profile);
  throw WebR::Exception::DFV($c) unless $c->form->success();

and have the error template format the errors than to process the
$c->form->msgs into an error string in my controller and chuck it back to
the user by way of my error template.

Cxx






More information about the Catalyst mailing list