Moose->throw_error('Usage: has \'name\' => ( key => value, ... )')
if @_ % 2 == 1;
- my %options = ( definition_context => Moose::Util::_caller_info(), @_ );
+ my %context = Moose::Util::_caller_info;
+ $context{context} = 'has declaration';
+ $context{type} = 'class';
+ my %options = ( definition_context => \%context, @_ );
my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
$meta->add_attribute( $_, %options ) for @$attrs;
}
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);
my $meta = shift;
my $name = shift;
croak 'Usage: has \'name\' => ( key => value, ... )' if @_ == 1;
- my %options = ( definition_context => Moose::Util::_caller_info(), @_ );
+ my %context = Moose::Util::_caller_info;
+ $context{context} = 'has declaration';
+ $context{type} = 'role';
+ my %options = ( definition_context => \%context, @_ );
my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
$meta->add_attribute( $_, %options ) for @$attrs;
}
my $level = @_ ? ($_[0] + 1) : 2;
my %info;
@info{qw(package file line)} = caller($level);
- return \%info;
+ return %info;
}
sub _create_alias {