Subject: | RaiseError does not work |
I noticed that the "RaiseError" attribute does not work at all. No
exception (die) is raised when an error occurs. It's a problem for
those who use the module in code based on exceptions and do not check
return values for errors because they assume that exceptions will be
raised.
A trivial example is attached, which only prints out a warning, die()
is not called. Is there something I miss, or is it a problem in
DBD-SQLite ? The other DBD modules that I have used really do call
die() on such errors.
From the DBI manual:
"RaiseError" (boolean, inherited)
The "RaiseError" attribute can be used to force errors to raise
exceptions rather than simply return error codes in the normal way. It
is "off" by default. When set "on", any method which results in an
error will cause the DBI to effectively do a "die("$class $method
failed: $DBI::errstr")", where $class is the driver class and $method
is the name of the method that failed.
Subject: | die.pl |
#!/usr/bin/perl
use strict;
use DBI;
my $dbh = DBI->connect("dbi:SQLite:dbname=test.db", {
RaiseError => 1,
PrintError => 0,
});
my $h = $dbh->selectrow_hashref("
SELECT *
FROM nonexisting
WHERE id = ?
", undef, 3);
print "after die\n";