From: Shawn M Moore Date: Sun, 2 Nov 2008 16:29:34 +0000 (+0000) Subject: Throw an error if a method eval fails X-Git-Tag: 0.19~160 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=71b948d1bbe4fc13f4cfd19aa78301339f5f48ec;p=gitmo%2FMouse.git Throw an error if a method eval fails --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index d918e3d..581ca5f 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -120,7 +120,9 @@ sub generate_accessor { $accessor .= 'return $self->{$key}; }'; - return eval $accessor; + my $sub = eval $accessor; + confess $@ if $@; + return $sub; } sub generate_predicate { @@ -129,16 +131,20 @@ sub generate_predicate { my $predicate = 'sub { exists($_[0]->{$key}) }'; - return eval $predicate; + my $sub = eval $predicate; + confess $@ if $@; + return $sub; } sub generate_clearer { my $attribute = shift; my $key = $attribute->name; - my $predicate = 'sub { delete($_[0]->{$key}) }'; + my $clearer = 'sub { delete($_[0]->{$key}) }'; - return eval $predicate; + my $sub = eval $clearer; + confess $@ if $@; + return $sub; } sub generate_handles { @@ -157,6 +163,7 @@ sub generate_handles { }'; $method_map{$local_method} = eval $method; + confess $@ if $@; } return \%method_map;