Another eval => try
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI.pm
index 98c9f91..0e1b103 100644 (file)
@@ -1014,7 +1014,7 @@ sub _server_info {
 
     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) {
@@ -1172,7 +1172,8 @@ sub _connect {
     $DBI::connect_via = 'connect';
   }
 
-  eval {
+  my $caught;
+  try {
     if(ref $info[0] eq 'CODE') {
        $dbh = $info[0]->();
     }
@@ -1197,12 +1198,14 @@ sub _connect {
       $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});
 
@@ -1711,20 +1714,25 @@ sub _dbh_execute_array {
 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;
 }