http://www.perlmonks.org?node_id=382338


in reply to Better way to catch Class::DBI constraint failures?

I encountered this problem a few months ago and spent a little time investigating.

To understand what's going on, take a look at the source for Class::DBI's add_constraint method. Constraints are just before_set triggers that, on failure, croak with the error message you observed.

So, if you wrote a before_set_namespace trigger, you could behave as you choose on error.

The particular problem I encountered was that I wanted to list all failed constraints. I used a combination of triggers and two layers Exception::Class events.

I apologise if this seems a little vague: I don't have access to the code any more and don't recall exactly what I did.

Oh, and of course Perl modules can be cool. Distrust anyone who claims otherwise.

Replies are listed 'Best First'.
Re^2: Better way to catch Class::DBI constraint failures?
by Hero Zzyzzx (Curate) on Aug 12, 2004 at 17:09 UTC
    So, if you wrote a before_set_namespace trigger, you could behave as you choose on error.

    I'm probably being dense, but: How? I put in a before_set_namespace trigger and I was getting the same error message, just in a different way.

    -Any sufficiently advanced technology is
    indistinguishable from doubletalk.

    My Biz