Re: [Maypole] catching DB errors

From: Toby Corkindale (maypole at wintrmute.net)
Date: Wed Jan 26 2005 - 14:54:01 GMT


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.

btw, can I put a generic version in the driver class, or does it have to be
in every model class?

> 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.

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.

Thanks, that should help a lot,
Toby

_______________________________________________
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