Following an example in "Programming the Perl DBI" concerning error handling for transactions (which recently seen implemented Randal Schwartz's "Perl of Wisdom" column in this month's "Linux Magazine"), I tried doing something similiar with a test (which of course will be expanded into actual application later):
my $dbh = DBI->connect("dbi:Pg:dbname=test_db", $user, $pass, { RaiseE
+rror => 1, AutoCommit => 0 });
eval {
$dbh->do('UPDATE a SET x = y');
$dbh->commit();
};
if ($@) {
warn "flurg!: $@";
}
The problem is the output in my logs is: 'flurg!: '
$@ is not being printed. However, if I print $DBI::errstr instead in the warning, I get the expected error (eg: table a doesn't exist).
I am sure this is all is my fault and I've just misused the examples.
--
notsoevil
--
Jeremiah 49:32 - And their camels shall be a booty. . .
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.