Re: [Maypole] catching DB errors

From: Simon Flack (sf at flacks.net)
Date: Wed Jan 26 2005 - 13:25:20 GMT


Toby Corkindale wrote:
[snip]
>>>Have you read teh Maypole::Manual::Request error handling section? I follow
>>>that model, then when i come to an error just do a "return $r->error("Error.
>>>we're dead")" .
>>
>>I've read it, but it's not really clear how the error () routine it suggests
>>is supposed to behave wrt fatal exceptions etc?
>>
>>I'll experiment some more.
>>Thanks for the tip.
>
>
> (Replying to myself; first sign of madness?)
>
> 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.

The default $r->exception just returns Maypole::Constants::ERROR and you
should end up with the error sent to STDERR. If you have enabled
$r->debug, Maypole should also output the error and return ERROR to the
handler. I'm not sure how Apache translates that into a 404. It's also
possible that something else entirely is happening.

If you want to deal with fatal errors differently, you can define your
own $r->exception() or add model-specific 'exception' handlers to each
of your model classes.

HTH
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