Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Better way to catch Class::DBI constraint failures?

by tomhukins (Curate)
on Aug 12, 2004 at 16:17 UTC ( #382338=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://382338]
help
Chatterbox?
[choroba]: The problem was bigger, as the test tried to call a method that didn't exist anymore
[marinersk]: :: ducking ::
[choroba]: because, someone renamed the method, but didn't notice it was used in the test, as the test was skipped
[marinersk]: Well, if the method doesn't exist, it would be hard to pass the test.
[choroba]: later, someone removed the new method, as all its usage places were safe, but didn't notice the test still used the old name
[choroba]: fortunately, it wasn't that hard to replace the method and fix a few remaining failures due to the changes we did to the codebase over the years
[marinersk]: choroba Sounds like a process improvement opportunity; tests may not all need to be run, but they should all be compiled with perl -c before check-in/promotion happens.
[choroba]: so, now I have the test, so I can start making changes in the code. Back to the original ticket, yay!
[marinersk]: I definitely love it when my $current_taask=& taskPop(); if ($current_task eq $original_task) { } is true.
[marinersk]: s/taask/task/g;

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2017-05-25 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?