use strict;
use warnings;
-use Carp ();
+use Carp::Clan qw/^DBIx::Class/;
sub new {
my ($class, $storage) = @_;
return if $dismiss;
my $exception = $@;
- Carp::cluck("A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or an error - bad")
+
+ carp 'A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back.'
unless $exception;
my $rollback_exception;
eval { $storage->txn_rollback };
$rollback_exception = $@;
}
+
if ($rollback_exception && $rollback_exception !~ /DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION/) {
- $storage->throw_exception(
- "Transaction aborted: ${exception} "
- . "Rollback failed: ${rollback_exception}"
- );
+ if ($exception) {
+ $@ = "Transaction aborted: ${exception} "
+ ."Rollback failed: ${rollback_exception}";
+ }
+ else {
+ # throws an object (verified with eval{}) but DESTROY eats the exception
+ $storage->throw_exception ("Rollback failed: ${rollback_exception}");
+ }
}
}