summaryrefslogtreecommitdiff
path: root/Data-MultiValued/lib/Data/MultiValued/Exceptions.pm
blob: 8d444c01c086d6de1ef49e5f34d947b618668856 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package Data::MultiValued::Exceptions; 
package Data::MultiValued::Exceptions::NotFound;{ 
use Moose;
extends 'Throwable::Error';
 
has value => (
    is => 'ro',
    required => 1,
);
 
sub as_string {
    my ($self) = @_;
 
    my $str = $self->message . ($self->value // '<undef>');
    $str .= "\n\n" . $self->stack_trace->as_string;
 
    return $str;
}
 
}
package Data::MultiValued::Exceptions::TagNotFound;{ 
use Moose;
extends 'Data::MultiValued::Exceptions::NotFound';
 
has '+message' => (
    default => 'tag not found: ',
);
}
package Data::MultiValued::Exceptions::RangeNotFound;{ 
use Moose;
extends 'Data::MultiValued::Exceptions::NotFound';
 
has '+message' => (
    default => 'no range found for value ',
);
}
package Data::MultiValued::Exceptions::BadRange;{ 
use Moose;
extends 'Throwable::Error';
 
has ['from','to'] => ( is => 'ro'required => 1 );
has '+message' => (
    default => 'invalid range: ',
);
 
sub as_string {
    my ($self) = @_;
 
    my $str = $self->message . $self->from . '' . $self->to;
    $str .= "\n\n" . $self->stack_trace->as_string;
 
    return $str;
}
 
}
 
1;