package MooseX::Antlers::EvalTracker;
use Moose;
+use MooseX::Antlers::ErrorThrower;
use Scalar::Util qw(weaken refaddr);
use PadWalker qw(closed_over);
use Sub::Identify qw(sub_fullname);
# _eval_closure returns a CODE ref and we want that too
sub {
my $self = shift;
- # ... screwed over here by $attr->default(...) and ->trigger(...)
- # in the bloody inlined subs. XXX slap stevan, fix Moose
- # until we stop passing these let's make anything that uses it
- # crash out so at least we don't break anything
- #delete @{$_[0]}{qw($meta $attr)};
- my $cr = $self->$orig(@_);
- $eval_tracker->_eval_closure_called_for($cr => @_);
- return $cr;
+ if ($_[0]->{'$attr'} || $_[0]->{'$attrs'}) {
+ die "Closing over meta-attribute, can't handle this. Suspect you used initializer - can't support that yet, sorry. Patches welcome.";
+ }
+ $_[0]->{'$meta'} = \'MooseX::Antlers::ErrorThrower';
+ my ($cr, $e) = $self->$orig(@_);
+ $eval_tracker->_eval_closure_called_for($cr => @_) unless $e;
+ return ($cr, $e);
};
}