X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FClass-MOP.git;a=blobdiff_plain;f=lib%2FClass%2FMOP%2FMethod%2FConstructor.pm;fp=lib%2FClass%2FMOP%2FMethod%2FConstructor.pm;h=05c8d925c62dd9f7c092794354468bab3e0d398b;hp=d614587b471a8dda2193db7be55748a53c1fd210;hb=15961c86cfd845e6f46b6c362cc1a4b94ffb45db;hpb=5f90deee7aaaa91b691b9bee49ed681daa311b69 diff --git a/lib/Class/MOP/Method/Constructor.pm b/lib/Class/MOP/Method/Constructor.pm index d614587..05c8d92 100644 --- a/lib/Class/MOP/Method/Constructor.pm +++ b/lib/Class/MOP/Method/Constructor.pm @@ -6,6 +6,7 @@ use warnings; use Carp 'confess'; use Scalar::Util 'blessed', 'weaken'; +use Try::Tiny; our $VERSION = '1.11'; $VERSION = eval $VERSION; @@ -121,11 +122,15 @@ sub _generate_constructor_method_inline { $source .= ";\n" . '}'; warn $source if $self->options->{debug}; - my ( $code, $e ) = $self->_eval_closure( - $close_over, - $source - ); - confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$e" if $e; + my $code = try { + $self->_compile_code( + source => $source, + environment => $close_over, + ); + } + catch { + confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$_"; + }; return $code; }