From: Yuval Kogman Date: Sun, 10 Aug 2008 18:55:21 +0000 (+0000) Subject: localize $@ more X-Git-Tag: 0_64_01~51 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1b8d9282186669a209a40383d2d72a4cef4a5f3b;p=gitmo%2FClass-MOP.git localize $@ more --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 8667238..c5c1a68 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -82,6 +82,7 @@ BEGIN { # module and use that as a means # for naming our CVs, if not, we # use the workaround instead. + local $@; if ( eval { require Sub::Name } ) { *subname = \&Sub::Name::subname; } @@ -129,17 +130,17 @@ sub load_class { # require it my $file = $class . '.pm'; $file =~ s{::}{/}g; - eval { CORE::require($file) }; - confess "Could not load class ($class) because : $@" if $@; + my $e = do { local $@; eval { require($file) }; $@ }; + confess "Could not load class ($class) because : $e" if $e; } # initialize a metaclass if necessary unless (does_metaclass_exist($class)) { - eval { Class::MOP::Class->initialize($class) }; - confess "Could not initialize class ($class) because : $@" if $@; + my $e = do { local $@; eval { Class::MOP::Class->initialize($class) }; $@ }; + confess "Could not initialize class ($class) because : $e" if $e; } - return get_metaclass_by_name($class); + return get_metaclass_by_name($class) if defined wantarray; } sub is_class_loaded {