From: Shawn M Moore Date: Sun, 18 May 2008 21:49:35 +0000 (+0000) Subject: Improve the error message of having a plain reference in 'default' X-Git-Tag: 0_64~61 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c0a80878fdb1cf4f552c9abff0fc50fb51ad77a;p=gitmo%2FClass-MOP.git Improve the error message of having a plain reference in 'default' --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 47a65f1..adb2f9d 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -426,7 +426,7 @@ Class::MOP::Attribute->meta->add_method('new' => sub { } else { (Class::MOP::Attribute::is_default_a_coderef(\%options)) || confess("References are not allowed as default values, you must ". - "wrap then in a CODE reference (ex: sub { [] } and not [])") + "wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])") if exists $options{default} && ref $options{default}; } # return the new object diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index c3d760b..02cfae9 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -41,7 +41,7 @@ sub new { } else { (is_default_a_coderef(\%options)) || confess("References are not allowed as default values, you must ". - "wrap then in a CODE reference (ex: sub { [] } and not [])") + "wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])") if exists $options{default} && ref $options{default}; } if( $options{required} and not( defined($options{builder}) || defined($options{init_arg}) || exists $options{default} ) ) {