X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FAttribute.pm;h=46a8412f0ecd474a7641091acfeb3475864c798c;hb=a917d5ae83dc260c6a84fed0ffdc0d1b70c50266;hp=973b7b105d7e66069937206827674bf95618cc94;hpb=94d3459a4ba4611d3712bf0a0dff62e9a8a02305;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 973b7b1..46a8412 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -94,7 +94,22 @@ sub new { if (@bad) { - Carp::cluck "Found unknown argument(s) passed to '$name' attribute constructor in '$class': @bad"; + my $s = @bad > 1 ? 's' : ''; + my $list = join "', '", @bad; + + my $package = $options{definition_context}{package}; + my $context = $options{definition_context}{context} + || 'attribute constructor'; + my $type = $options{definition_context}{type} || 'class'; + + my $location = ''; + if (defined($package)) { + $location = " in "; + $location .= "$type " if $type; + $location .= $package; + } + + Carp::cluck "Found unknown argument$s '$list' in the $context for '$name'$location"; } return $class->SUPER::new($name, %options); @@ -648,8 +663,7 @@ sub _inline_check_required { return ( 'if (@_ < 2) {', $self->_inline_throw_error( - '"Attribute (' . $attr_name . ') is required, so cannot ' - . 'be set to undef"' # defined $_[1] is not good enough + '"Attribute (' . $attr_name . ') is required"' ) . ';', '}', );