X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FTxnScopeGuard.pm;h=7f93113ac7ea53025b22a8177305493539c88989;hb=fd323bf1046faa7de5a8c985268d80ec5b703361;hp=459931cbc110eb14e5c3798f90cc47ed21cb6261;hpb=48580715af3072905f2c71dc27e7f70f21a11338;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/TxnScopeGuard.pm b/lib/DBIx/Class/Storage/TxnScopeGuard.pm index 459931c..7f93113 100644 --- a/lib/DBIx/Class/Storage/TxnScopeGuard.pm +++ b/lib/DBIx/Class/Storage/TxnScopeGuard.pm @@ -3,6 +3,8 @@ package DBIx::Class::Storage::TxnScopeGuard; use strict; use warnings; use Carp::Clan qw/^DBIx::Class/; +use Try::Tiny; +use namespace::clean; sub new { my ($class, $storage) = @_; @@ -31,10 +33,11 @@ sub DESTROY { carp 'A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back.' unless $exception; - eval { $storage->txn_rollback }; - my $rollback_exception = $@; + my $rollback_exception; + try { $storage->txn_rollback } + catch { $rollback_exception = shift }; - if ($rollback_exception && $rollback_exception !~ /DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION/) { + if (defined $rollback_exception && $rollback_exception !~ /DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION/) { if ($exception) { $exception = "Transaction aborted: ${exception} " ."Rollback failed: ${rollback_exception}"; @@ -76,7 +79,7 @@ DBIx::Class::Storage::TxnScopeGuard - Scope-based transaction handling =head1 DESCRIPTION An object that behaves much like L, but hardcoded to do the -right thing with transactions in DBIx::Class. +right thing with transactions in DBIx::Class. =head1 METHODS