Hero Zzyzzx has asked for the wisdom of the Perl Monks concerning the following question:
Folks,
I've just started using the mindblowing Class::DBI and I have to say it's just about the coolest module ever. *
What I REALLY want to do is find a more elegant way of catching specific CDBI::constraint failures- I've overridden CDBI::_croak in my base class, but the info I get back isn't all that useful.
The %info hash returns a reference to the Namespace object and an example error message is:
Namespace namespace fails 'list' constraint with 'page'Where "Namespace" is a CDBI subclass, the field is "namespace" and the constraint was: Namespace->constrain_column(namespace=>[qw/foo/]);
I can parse this error message, but I fear that I can't rely on the text of the error message in perpetuity and that different constraints may throw different errors now or at some other point in time.
The reason I want to catch constraint failures is because I want the constraint checking to act as my HTML form validation check: If the constraint check barfs, I want to re-output the form with an error message on the field that failed. Without an easy way to know which field failed, this won't be easy. Using CDBI constraints to check form values seems like a pretty good way to not repeat myself. . . but I need to give the user specific feedback about the failure.
Ideas? Thanks in advance.
* Assuming that perl modules can be cool in the first place. :)
-Any sufficiently advanced technology is
indistinguishable from doubletalk.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Better way to catch Class::DBI constraint failures?
by tomhukins (Curate) on Aug 12, 2004 at 16:17 UTC | |
by Hero Zzyzzx (Curate) on Aug 12, 2004 at 17:09 UTC | |
Re: Better way to catch Class::DBI constraint failures?
by Aristotle (Chancellor) on Aug 13, 2004 at 01:58 UTC | |
by Hero Zzyzzx (Curate) on Aug 13, 2004 at 03:48 UTC |