[Bast-commits] r7637 - in DBIx-Class/0.08/trunk: lib/DBIx/Class/Storage t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Fri Sep 11 23:31:16 GMT 2009


Author: ribasushi
Date: 2009-09-11 23:31:16 +0000 (Fri, 11 Sep 2009)
New Revision: 7637

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm
   DBIx-Class/0.08/trunk/t/81transactions.t
Log:
Final scopeguard tweak (?)

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm	2009-09-11 23:27:17 UTC (rev 7636)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm	2009-09-11 23:31:16 UTC (rev 7637)
@@ -41,8 +41,12 @@
           ."Rollback failed: ${rollback_exception}";
     }
     else {
-      # throws an object (verified with eval{}) but DESTROY eats the exception
-      $storage->throw_exception ("Rollback failed: ${rollback_exception}");
+      carp (join ' ',
+        "********************* ROLLBACK FAILED!!! ********************",
+        "\nA rollback operation failed after the guard went out of scope.",
+        'This is potentially a disastrous situation, check your data for',
+        "consistency: $rollback_exception"
+      );
     }
   }
 }

Modified: DBIx-Class/0.08/trunk/t/81transactions.t
===================================================================
--- DBIx-Class/0.08/trunk/t/81transactions.t	2009-09-11 23:27:17 UTC (rev 7636)
+++ DBIx-Class/0.08/trunk/t/81transactions.t	2009-09-11 23:31:16 UTC (rev 7637)
@@ -329,23 +329,22 @@
   }, qr/Deliberate exception.+Rollback failed/s);
 }
 
-# make sure it warns and dies on failed rollbacks
-TODO: {
+# make sure it warns *big* on failed rollbacks
+{
   my $schema = DBICTest->init_schema();
 
-  local $TODO = "Can't die in DESTROY :(";
-
-  throws_ok (sub {
-    warnings_exist (sub {
+  warnings_exist (sub {
       my $guard = $schema->txn_scope_guard;
       $schema->resultset ('Artist')->create ({ name => 'bohhoo'});
 
       $schema->storage->disconnect;  # this should freak out the guard rollback
-
     },
-    qr/A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back./,
-    'out-of-scope warning');
-  }, qr/Rollback failed:/, 'rollback error thrown' );
+    [
+      qr/A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back./,
+      qr/\*+ ROLLBACK FAILED\!\!\! \*+/,
+    ],
+    'proper warnings generated on out-of-scope+rollback failure'
+  );
 }
 
 done_testing;




More information about the Bast-commits mailing list