errstr()
$handle->errstr()This function returns any error messages from the last driver method called.
...
my $dbh = DBI->connect('DBI:mysql:bookstore:localhost','username',
'wrong_password')
|| die DBI->errstr;Notice the errstr() method is added to
the end of the database handle as part of the die
function from Perl. Here are the results of executing this
connect() with the wrong password:
DBI connect('bookstore:localhost','russell',...) failed:
Access denied for user 'russell'@'localhost' (using password: YES)
at ./dbi_test_program.plx line 8...Notice that the error message does not display the password given.