fix silent Oracle connection failures
Rafael Kitover [Sun, 24 Jun 2012 17:42:46 +0000 (13:42 -0400)]
::Storage::DBI::_server_info was eating connection exceptions by
ignoring exceptions from $dbh->get_info, but this information is
important for _rebless when e.g. determining which class to use based on
the DB server version, so rethrow the exceptions when
$self->{_in_determine_driver} is true.

lib/DBIx/Class/Storage/DBI.pm

index 45afefc..846bcca 100644 (file)
@@ -1075,7 +1075,16 @@ sub _server_info {
 
     $info = {};
 
-    my $server_version = try { $self->_get_server_version };
+    my $server_version;
+    try {
+      $server_version = $self->_get_server_version;
+    }
+    catch {
+      if ($self->{_in_determine_driver}) {
+        $self->throw_exception($_);
+      }
+      $server_version = undef;
+    };
 
     if (defined $server_version) {
       $info->{dbms_version} = $server_version;
@@ -1119,7 +1128,19 @@ sub _dbh_get_info {
       unless defined $info;
   }
 
-  return try { $self->_get_dbh->get_info($info) } || undef;
+  my $res;
+  
+  try {
+    $res = $self->_get_dbh->get_info($info);
+  }
+  catch {
+    if ($self->{_in_determine_driver}) {
+      $self->throw_exception($_);
+    }
+    $res = undef;
+  };
+
+  return $res;
 }
 
 sub _determine_driver {