my $server_version = do {
local $@; # might be happenin in some sort of destructor
- eval { $self->_get_server_version };
+ try { $self->_get_server_version };
};
if (defined $server_version) {
$DBI::connect_via = 'connect';
}
- eval {
+ my $caught;
+ try {
if(ref $info[0] eq 'CODE') {
$dbh = $info[0]->();
}
$dbh->{RaiseError} = 1;
$dbh->{PrintError} = 0;
}
+ } catch {
+ $caught = 1;
};
$DBI::connect_via = $old_connect_via if $old_connect_via;
$self->throw_exception("DBI Connection failed: " . ($@||$DBI::errstr))
- if !$dbh || $@;
+ if !$dbh || $caught;
$self->_dbh_autocommit($dbh->{AutoCommit});
sub _dbh_execute_inserts_with_no_binds {
my ($self, $sth, $count) = @_;
- eval {
+ my $exception;
+ try {
my $dbh = $self->_get_dbh;
local $dbh->{RaiseError} = 1;
local $dbh->{PrintError} = 0;
$sth->execute foreach 1..$count;
+ } catch {
+ $exception = shift;
};
- my $exception = $@;
# Make sure statement is finished even if there was an exception.
- eval { $sth->finish };
- $exception = $@ unless $exception;
+ try {
+ $sth->finish
+ } catch {
+ $exception = shift unless defined $exception;
+ };
- $self->throw_exception($exception) if $exception;
+ $self->throw_exception($exception) if defined $exception;
return $count;
}