From: gfx Date: Sat, 19 Dec 2009 07:10:36 +0000 (+0900) Subject: Change the signature of verify_type_constraint_error [IMCOMPATIBLE] X-Git-Tag: 0.45~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2a96ea8598dea995d57fa05e73cf2d42cf567e28;p=gitmo%2FMouse.git Change the signature of verify_type_constraint_error [IMCOMPATIBLE] --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 98dd81b..c4b749e 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -238,13 +238,17 @@ sub verify_against_type_constraint { return 1 if !$type_constraint; return 1 if $type_constraint->check($value); - $self->verify_type_constraint_error($self->name, $value, $type_constraint); + $self->verify_type_constraint_error($value, $type_constraint); } sub verify_type_constraint_error { - my($self, $name, $value, $type) = @_; - $self->throw_error("Attribute ($name) does not pass the type constraint because: " - . $type->get_message($value)); + my($self, $value, $type) = @_; + + $self->throw_error( + sprintf q{Attribute (%s) does not pass the type constraint because: %s}, + $self->name, + $type->get_message($value), + ); } sub coerce_constraint { # DEPRECATED diff --git a/lib/Mouse/Meta/Method/Accessor.pm b/lib/Mouse/Meta/Method/Accessor.pm index 46cbbc1..be8d9ff 100755 --- a/lib/Mouse/Meta/Method/Accessor.pm +++ b/lib/Mouse/Meta/Method/Accessor.pm @@ -49,7 +49,7 @@ sub _generate_accessor_any{ $accessor .= "\n". '$compiled_type_constraint->('.$value.') or - $attribute->verify_type_constraint_error($name, '.$value.', $constraint);' . "\n"; + $attribute->verify_type_constraint_error('.$value.', $constraint);' . "\n"; } # if there's nothing left to do for the attribute we can return during @@ -96,7 +96,7 @@ sub _generate_accessor_any{ $accessor .= "my \$tmp = $value;\n"; $accessor .= "\$compiled_type_constraint->(\$tmp)"; - $accessor .= " || \$attribute->verify_type_constraint_error(\$name, \$tmp, \$constraint);\n"; + $accessor .= " || \$attribute->verify_type_constraint_error(\$tmp, \$constraint);\n"; $accessor .= "$slot = \$tmp;\n"; } else{ diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index a96977d..deed6b0 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -77,7 +77,7 @@ sub _generate_processattrs { my $post_process = ''; if(defined $type_constraint){ $post_process .= "\$checks[$index]->($instance_slot)"; - $post_process .= " or $attr_var->verify_type_constraint_error(q{$key}, $instance_slot, $constraint_var);\n"; + $post_process .= " or $attr_var->verify_type_constraint_error($instance_slot, $constraint_var);\n"; } if($is_weak_ref){ $post_process .= "Scalar::Util::weaken($instance_slot) if ref $instance_slot;\n";