line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSONSchema::Validator::Error; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Error class |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
37
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
152
|
|
6
|
6
|
|
|
6
|
|
26
|
use warnings; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
336
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload |
9
|
4
|
|
|
4
|
|
18
|
'""' => sub { $_[0]->to_string }, |
10
|
6
|
|
|
6
|
|
34
|
fallback => 1; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
50
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = 'Exporter'; |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(error); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub error { |
16
|
498
|
|
|
498
|
0
|
1290
|
return __PACKAGE__->new(@_); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
498
|
|
|
498
|
0
|
1569
|
my ($class, %params) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return bless { |
23
|
|
|
|
|
|
|
message => $params{message}, |
24
|
|
|
|
|
|
|
context => $params{context} // [], |
25
|
|
|
|
|
|
|
# parent => $params{parent}, |
26
|
|
|
|
|
|
|
instance_path => $params{instance_path}, |
27
|
|
|
|
|
|
|
schema_path => $params{schema_path} |
28
|
498
|
|
100
|
|
|
3137
|
}, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
0
|
0
|
sub context { shift->{context} } |
32
|
4
|
|
|
4
|
0
|
10
|
sub message { shift->{message} } |
33
|
4
|
|
|
4
|
0
|
8
|
sub instance_path { shift->{instance_path} } |
34
|
4
|
|
|
4
|
0
|
8
|
sub schema_path { shift->{schema_path} } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub to_string { |
37
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
38
|
4
|
|
|
|
|
12
|
my $msg = $self->message; |
39
|
4
|
|
|
|
|
12
|
my $instance_path = $self->instance_path; |
40
|
4
|
|
|
|
|
12
|
my $schema_path = $self->schema_path; |
41
|
4
|
50
|
|
|
|
19
|
$msg .= " [instance path: ${instance_path}]" if $instance_path; |
42
|
4
|
50
|
|
|
|
14
|
$msg .= " [schema path: ${schema_path}]" if $schema_path; |
43
|
4
|
|
|
|
|
690
|
return $msg; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub unwind_to_string_list { |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
|
return [$self->to_string] unless @{$self->context}; |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $res = []; |
51
|
0
|
|
|
|
|
|
my $msg = $self->message; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
for my $err (@{$self->context}) { |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
for my $err_str (@{$err->unwind_to_string_list}) { |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
push @$res, "$msg: $err_str"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $res; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub TO_JSON { |
63
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
my $res = { |
65
|
|
|
|
|
|
|
message => $self->message |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
$res->{instance_path} = $self->instance_path |
69
|
|
|
|
|
|
|
if $self->instance_path; |
70
|
0
|
0
|
|
|
|
|
$res->{schema_path} = $self->schema_path |
71
|
|
|
|
|
|
|
if $self->schema_path; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
if (@{$self->context}) { |
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$res->{context} = [ |
75
|
0
|
|
|
|
|
|
map { $_->TO_JSON } |
76
|
0
|
|
|
|
|
|
@{$self->context} |
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
]; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $res; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |