Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where on earth are my errors messages?

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

I have some DBI code wrapped in a try/catch (Try::Tiny) clause.
Code:
try
{
        # Run SQL Command
        my $sth = $db->prepare("$sel") || die "Error in getSQL ($error): $sel";
        $sth->execute();
}
catch
{
        die "$_ - $! - $@ - $DBI::errstr - $DBI::err";
};

Any error from try tiny is meant to be passed to the catch clause via $_,

As you can see I've tried every error variable I can think off, but all I get output is
- - - - -

How do I find out why the code is falling over?

Where is the error message?

Thanks,
1DMF


"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I don't know what is going on but it seems impossible to use DBI & Try::Tiny.

I found that using warnings and carp was taking away any catch clause error message.

So I stopped using warnings and carp and now DBI is throwing some ridiculous error that isn't true and still $_ is empty in the catch clause and I have to use $!

I do a simple insert of a record into a table and the try::catch is triggering with a message.

Result too large

Huh? What result? The only return I ask for from DBI is number of records inserted
Code:
$rec = $sth->rows;

Which is 1, how can that be too large?

1DMF <<<< baffled!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I'm not sure what DBI is doing, but no matter what I am unable to put my code in a Try::Tiny clause without it triggering failure.

I switched to an eval and it seems to work fine?

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top