my $dbh = try { DBI->connect( $conn_string, $props{USER}, $props{PWD}, { PrintError => 0, RaiseError => 1, }, ) } otherwise { throw Error::Database -text => ( $DBI::errstr || $@ || "Unknown Error: '$conn_string'" ); }; $dbh->{HandleError} = sub { throw Error::Database -text => $DBI::errstr }; return $dbh;