From: Shawn M Moore Date: Sun, 13 Jan 2008 05:03:00 +0000 (+0000) Subject: Change the error message for when you rebless into a non-subclass. If anyone has... X-Git-Tag: 0_51~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=de0d4f939dec6cd53dcd304bb8dfca4f24ca47cb;p=gitmo%2FClass-MOP.git Change the error message for when you rebless into a non-subclass. If anyone has a better one, go ahead and commit it. I wash my hands of this dirty deed. :) --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 7ac3f06..7d47e17 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -399,7 +399,7 @@ sub rebless_instance { my $meta_instance = $self->get_meta_instance(); $self->name->isa($old_metaclass->name) - || confess "You may rebless only into a subclass. (". $self->name .") is not a subclass of (". $old_metaclass->name .")."; + || confess "You may rebless only into a subclass of (". $old_metaclass->name ."), of which (". $self->name .") isn't."; # rebless! $meta_instance->rebless_instance_structure($instance, $self); diff --git a/t/046-rebless.t b/t/046-rebless.t index a6baa40..5ee4b7c 100644 --- a/t/046-rebless.t +++ b/t/046-rebless.t @@ -44,10 +44,10 @@ is($foo->parent, "parent", 'reblessed->parent gives parent'); is($foo->child, "child", 'reblessed->child gives child'); throws_ok { LeftField->meta->rebless_instance($foo, "LeftField") } - qr/You may rebless only into a subclass. \(LeftField\) is not a subclass of \(Child\)\./; + qr/You may rebless only into a subclass of \(Child\), of which \(LeftField\) isn't\./; throws_ok { Class::MOP::Class->initialize("NonExistent")->rebless_instance($foo) } - qr/You may rebless only into a subclass. \(NonExistent\) is not a subclass of \(Child\)\./; + qr/You may rebless only into a subclass of \(Child\), of which \(NonExistent\) isn't\./; # make sure our ->meta is still sane my $bar = Parent->new;