Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


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.

My Biz

In reply to Better way to catch Class::DBI constraint failures? by Hero Zzyzzx

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2021-05-18 11:03 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (178 votes). Check out past polls.