From: Jesse Luehrs Date: Sun, 3 May 2009 01:25:55 +0000 (-0500) Subject: better error message for when global destruction messes with DEMOLISH X-Git-Tag: 0.78~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b33999a38f6949bf3d570a11750ef6b899d5d2bb;p=gitmo%2FMoose.git better error message for when global destruction messes with DEMOLISH --- diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index 191e7cb..5d29729 100644 --- a/lib/Moose/Object.pm +++ b/lib/Moose/Object.pm @@ -72,6 +72,12 @@ sub DEMOLISHALL { || Moose::Meta::Class->initialize( ref $self ); foreach my $method ( $meta->find_all_methods_by_name('DEMOLISH') ) { + $meta->throw_error( + "Couldn't call DEMOLISH on package $method->{class} because" + . " global destruction destroyed it first. Make sure all of" + . " your instances of $method->{class} are destroyed before" + . " global destruction to fix this." + ) if !$method->{code} && $in_global_destruction; $method->{code}->execute($self, $in_global_destruction); } }