Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • 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 wandering the Monastery: (8)
    As of 2020-11-30 12:24 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found