Another overhaul of transaction/savepoint handling
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / TxnScopeGuard.pm
index 9bda8bb..5b72f68 100644 (file)
@@ -2,27 +2,25 @@ package DBIx::Class::Storage::TxnScopeGuard;
 
 use strict;
 use warnings;
-use Carp::Clan qw/^DBIx::Class/;
 use Try::Tiny;
 use Scalar::Util qw/weaken blessed/;
 use DBIx::Class::Exception;
-use namespace::clean;
+use DBIx::Class::Carp;
 
 # temporary until we fix the $@ issue in core
 # we also need a real appendable, stackable exception object
 # (coming soon)
 BEGIN {
-  if ($] < 5.013001) {
-    *IS_BROKEN_PERL = sub () { 0 };
-  }
-  elsif ($] < 5.013008) {
+  if ($] >= 5.013001 and $] <= 5.013007) {
     *IS_BROKEN_PERL = sub () { 1 };
   }
   else {
-    die 'The $@ debacle should have been resolved by now, adjust DBIC';
+    *IS_BROKEN_PERL = sub () { 0 };
   }
 }
 
+use namespace::clean;
+
 my ($guards_count, $compat_handler, $foreign_handler);
 
 sub new {
@@ -124,7 +122,11 @@ sub DESTROY {
     try { $storage->_seems_connected && $storage->txn_rollback }
     catch { $rollback_exception = shift };
 
-    if (defined $rollback_exception && $rollback_exception !~ /DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION/) {
+    if ( $rollback_exception and (
+      ! defined blessed $rollback_exception
+          or
+      ! $rollback_exception->isa('DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION')
+    ) ) {
       # append our text - THIS IS A TEMPORARY FIXUP!
       # a real stackable exception object is in the works
       if (ref $exception eq 'DBIx::Class::Exception') {