From: Shawn M Moore Date: Tue, 10 Jun 2008 04:56:03 +0000 (+0000) Subject: Nonsensical (undef, empty, reference) class names now throw a more direct error in... X-Git-Tag: 0_64~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ab5e2f4804848cfabd7f3f46b2347a3f1743f3d3;p=gitmo%2FClass-MOP.git Nonsensical (undef, empty, reference) class names now throw a more direct error in load_class --- diff --git a/Changes b/Changes index eb8be57..bce3555 100644 --- a/Changes +++ b/Changes @@ -18,7 +18,10 @@ Revision history for Perl extension Class-MOP. to avoid a segfault - is_class_loaded check now uses code that was improved in Moose's ClassName type - check + check (Sartak) + - nonsensical (undef, empty, reference) class + names now throw a more direct error in + load_class (Sartak) * Class::MOP Class::MOP::Class diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 92af82a..cb22ff5 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -124,6 +124,12 @@ BEGIN { sub load_class { my $class = shift; + + if (ref($class) || !defined($class) || !length($class)) { + my $display = defined($class) ? $class : 'undef'; + confess "Invalid class name ($display)"; + } + # see if this is already # loaded in the symbol table return 1 if is_class_loaded($class);