in reply to Custom error messages and moose
Do you show me your error message? if I return undef to isa 'Str' attribute, I will see like this.
Attribute (ip_address) does not pass the type constraint because: Validation failed for 'Str' with value undef at reader test::ip_address (defined at 069.pl line 7) line 15
test::ip_address('test=HASH(0x284a2320)') called at 069.pl line 35
Or, Is there some reason you can't die like this ?
sub get_ip_address { my $self = shift; my $allclasses_file = $self->allclasses_file; my $ip_address; if ( $allclasses_file =~ m/_([^_]+$)/ ) { $ip_address = $1; return $ip_address; } else { die "not good ip\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Custom error messages and moose
by neilwatson (Priest) on Sep 29, 2012 at 12:09 UTC | |
by remiah (Hermit) on Sep 29, 2012 at 15:21 UTC |