my $dbh = DBI->connect("DBI:mysql:test:localhost", "user", "pass", { RaiseError => 0, PrintError => 0 } ); $dbh->{HandleError} = sub { print "Error received: $DBI::errstr\n"; exit; }; my $sth = $dbh->prepare("SELECT wibble FROM flubble"); $sth->execute();