}
sub _eval_code {
- my ( $self, $code ) = @_;
+ my ( $self, $source ) = @_;
# NOTE:
# set up the environment
: undef),
};
- #warn "code for $attr_name =>\n" . $code . "\n";
- $self->_compile_code( environment => $environment, code => $code )
- or $self->throw_error("Could not create writer for '${\$self->associated_attribute->name}' because $@ \n code: $code", error => $@, data => $code );
+ #warn "code for $attr_name =>\n" . $source . "\n";
+ my ( $code, $e ) = $self->_compile_code( environment => $environment, code => $source );
+
+ $self->throw_error(
+ "Could not create writer for '${\$self->associated_attribute->name}' because $e \n code: $source",
+ error => $e, data => $source )
+ if $e;
+
+ return $code;
}
sub _generate_accessor_method_inline {
defined $_ ? $_->_compiled_type_constraint : undef;
} @type_constraints;
- my $code = $self->_compile_code(
+ my ( $code, $e ) = $self->_compile_code(
code => $source,
environment => {
'$meta' => \$self,
'@type_constraints' => \@type_constraints,
'@type_constraint_bodies' => \@type_constraint_bodies,
},
- ) or $self->throw_error("Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source );
+ );
+
+ $self->throw_error(
+ "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$e",
+ error => $e, data => $source )
+ if $e;
$self->{'body'} = $code;
}
warn $source if $self->options->{debug};
- my $code = $self->_compile_code(
+ my ( $code, $e ) = $self->_compile_code(
environment => {},
code => $source,
- ) or $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source);
+ );
+
+ $self->throw_error(
+ "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$e",
+ error => $e, data => $source )
+ if $e;
$self->{'body'} = $code;
}