Toby Corkindale wrote:
> On Wed, Jan 26, 2005 at 01:25:20PM +0000, Simon Flack wrote:
>
>>Toby Corkindale wrote:
>
> [snip]
>
>>>However, I've tried putting an error subroutine into both the main driver
>>>class, and also the model classes too. In neither case was it actually
>>>called when the DB threw up an error.
>>
>>The 404 response you're getting intrigues me.
>>
>>Assuming your DB throws an error whilst processing a model action,
>>Maypole will call invoke an 'exception' method in your model class (if
>>such a method exists), or it will call $r->exception() if it doesn't.
>
>
> Ah, thanks.. I hadn't seen that feature before - I'll test it out now.
I doesn't look like it's in the documentation. I'll make a note of that.
> btw, can I put a generic version in the driver class, or does it have to be
> in every model class?
Yes, you can have a generic exception handler in your driver class. It
just gives a little extra flexibility to be able to define
model-specific exception handlers, but they're optional.
> I do see error info in the logs, but while in a testing phase I'd like to be
> able to catch the error and display a message including it on-screen..
> It sounds like the exception() method should do the trick for that though.
That sounds like a good idea. Your exception handler will need to return
Maypole::Constants::OK. A basic exception handler could look like this
(untested):
sub BeerDB::exception {
my ($r, $error) = @_;
$r->output("You've had too much to drink: $error");
return Maypole::Constants::OK;
}
$r->output() sets the output that Maypole will later send to the
browser. 'output' is a noun here rather than a verb.
While looking at this, I notice that there's already an $r->error()
which clashes with the $r->error() described in
Maypole::Manual::Request. We'll need to straighten that out.
Simon
_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT