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();
};
$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 {
}
$self->txn_commit;
} catch {
- my $error = $@;
+ my $error = shift;
try {
$self->txn_rollback;
} catch {
- my $rollback_error = $@;
+ my $rollback_error = shift;
my $exception_class = "DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION";
$self->throw_exception($error) # propagate nested rollback
if $rollback_error =~ /$exception_class/;