| 1 | package Exception::Validator::FailedField; | ||
| 2 | $Exception::Validator::FailedField::VERSION = '0.012'; | ||
| 3 | use base qw(Exception::Validator); | ||
| 4 | |||
| 5 | use Scalar::Util qw(blessed); | ||
| 6 | |||
| 7 | sub import { | ||
| 8 | FF->export_to_level(1); | ||
| 9 | } | ||
| 10 | |||
| 11 | sub new { | ||
| 12 | my ($this, $text, %data) = @_; | ||
| 13 | |||
| 14 | my $class = ref($this) || $this; | ||
| 15 | |||
| 16 | $text = '' if !defined $text; | ||
| 17 | |||
| 18 | my $self = { | ||
| 19 | %data, | ||
| 20 | ( | ||
| 21 | blessed($text) && $text->isa('Exception') | ||
| 22 | ? (text => $text->{'text'}, parent => $text) | ||
| 23 | : (text => $text) | ||
| 24 | ), | ||
| 25 | }; | ||
| 26 | |||
| 27 | return bless $self, $class; | ||
| 28 | } | ||
| 29 | |||
| 30 | sub as_string { | ||
| 31 | my ($self) = @_; | ||
| 32 | |||
| 33 | return ref($self) . ": $self->{'text'}\n" . ($self->{'parent'} ? "\n$self->{'parent'}\n" : ''); | ||
| 34 | } | ||
| 35 | |||
| 36 | package FF; | ||
| 37 | $FF::VERSION = '0.012'; | ||
| 38 | use base qw(Exception::Validator::FailedField Exporter); | ||
| 39 | |||
| 40 | 1; |