Fix TxnScopeGuard misbehaving on externally set $@ without inner exceptions
authorPeter Rabbitson <ribasushi@cpan.org>
Fri, 25 Nov 2011 22:20:44 +0000 (23:20 +0100)
committerPeter Rabbitson <ribasushi@cpan.org>
Fri, 25 Nov 2011 22:20:44 +0000 (23:20 +0100)
commitf62c57241fe47b0fe4ee5147f9a9b78f8d9725d1
tree05e5032adbbe6272ece68cf775554751fd2bde49
parent45638aed4f500330d6b63cecdcad25356026f392
Fix TxnScopeGuard misbehaving on externally set $@ without inner exceptions

The guard is supposed to warn when it goes out of scope without a commit.
However this doesn't work if $@ was already set before the guard was created
and there were no eval{}s to clear it between definition and destruction.

Fixing this by storing a weakref to the current exception (if any) and
disregarding the contents of $@ if they match the ref we started with.
Changes
lib/DBIx/Class/Storage/TxnScopeGuard.pm
t/storage/txn_scope_guard.t