From: Jesse Luehrs Date: Wed, 23 Sep 2009 02:17:21 +0000 (-0500) Subject: replace several uses of eval with try X-Git-Tag: 0.93~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1454efcc8ab4f8ae7eca856933d5a18a1e09e305;p=gitmo%2FMoose.git replace several uses of eval with try --- diff --git a/Changes b/Changes index 45cdbca..8b31dc8 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Also see Moose::Manual::Delta for more details of, and workarounds for, noteworthy changes. + * replace two more eval { } calls with try { } (doy) + 0.92 Tue, Sep 22, 2009 * Moose::Util::TypeConstraints - added the match_on_type operator (Stevan) diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 0e3fd5e..8f638f7 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -5,6 +5,7 @@ use strict; use warnings; use Scalar::Util 'blessed', 'weaken'; +use Try::Tiny; use overload (); our $VERSION = '0.92'; @@ -58,7 +59,7 @@ __PACKAGE__->meta->add_attribute('traits' => ( # for metatrait aliases. sub does { my ($self, $role_name) = @_; - my $name = eval { + my $name = try { Moose::Util::resolve_metatrait_alias(Attribute => $role_name) }; return 0 if !defined($name); # failed to load class @@ -318,7 +319,7 @@ sub _process_options { if (exists $options->{isa}) { if (exists $options->{does}) { - if (eval { $options->{isa}->can('does') }) { + if (try { $options->{isa}->can('does') }) { ($options->{isa}->does($options->{does})) || $class->throw_error("Cannot have an isa option and a does option if the isa does not do the does on attribute ($name)", data => $options); }