Skip tests segfaulting with ancient DBD::Sybase versions
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage.pm
index 08ea155..c4997d5 100644 (file)
@@ -10,6 +10,7 @@ use DBIx::Class::Exception;
 use Scalar::Util();
 use IO::File;
 use DBIx::Class::Storage::TxnScopeGuard;
+use Try::Tiny;
 
 __PACKAGE__->mk_group_accessors('simple' => qw/debug debugobj schema/);
 __PACKAGE__->mk_group_accessors('inherited' => 'cursor_class');
@@ -161,9 +162,10 @@ For example,
   try {
     $rs = $schema->txn_do($coderef);
   } catch {
+    my $error = shift;
     # Transaction failed
     die "something terrible has happened!"   #
-      if ($@ =~ /Rollback failed/);          # Rollback failed
+      if ($error =~ /Rollback failed/);          # Rollback failed
 
     deal_with_failed_transaction();
   };
@@ -194,7 +196,7 @@ sub txn_do {
   $self->txn_begin; # If this throws an exception, no rollback is needed
 
   my $wantarray = wantarray; # Need to save this since the context
-                             # inside the eval{} block is independent
+                             # inside the try{} block is independent
                              # of the context that called txn_do()
   try {
 
@@ -211,23 +213,23 @@ sub txn_do {
       $coderef->(@args);
     }
     $self->txn_commit;
-  } catch {
-    my $error = $@;
+  }
+  catch {
+    my $error = shift;
 
     try {
       $self->txn_rollback;
     } catch {
-      my $rollback_error = $@;
       my $exception_class = "DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION";
       $self->throw_exception($error)  # propagate nested rollback
-        if $rollback_error =~ /$exception_class/;
+        if $_ =~ /$exception_class/;
 
       $self->throw_exception(
-        "Transaction aborted: $error. Rollback failed: ${rollback_error}"
+        "Transaction aborted: $error. Rollback failed: $_"
       );
     }
     $self->throw_exception($error); # txn failed but rollback succeeded
-  }
+  };
 
   return $wantarray ? @return_values : $return_value;
 }