line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSONSchema::Validator::Error; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Error class |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
41
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
180
|
|
6
|
6
|
|
|
6
|
|
33
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
416
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload |
9
|
4
|
|
|
4
|
|
28
|
'""' => sub { $_[0]->to_string }, |
10
|
6
|
|
|
6
|
|
40
|
fallback => 1; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
47
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = 'Exporter'; |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(error); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub error { |
16
|
496
|
|
|
496
|
0
|
1670
|
return __PACKAGE__->new(@_); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
496
|
|
|
496
|
0
|
1992
|
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
|
496
|
|
100
|
|
|
3819
|
}, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
0
|
0
|
sub context { shift->{context} } |
32
|
4
|
|
|
4
|
0
|
14
|
sub message { shift->{message} } |
33
|
4
|
|
|
4
|
0
|
12
|
sub instance_path { shift->{instance_path} } |
34
|
4
|
|
|
4
|
0
|
11
|
sub schema_path { shift->{schema_path} } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub to_string { |
37
|
4
|
|
|
4
|
0
|
13
|
my $self = shift; |
38
|
4
|
|
|
|
|
13
|
my $msg = $self->message; |
39
|
4
|
|
|
|
|
10
|
my $instance_path = $self->instance_path; |
40
|
4
|
|
|
|
|
12
|
my $schema_path = $self->schema_path; |
41
|
4
|
50
|
|
|
|
21
|
$msg .= " [instance path: ${instance_path}]" if $instance_path; |
42
|
4
|
50
|
|
|
|
15
|
$msg .= " [schema path: ${schema_path}]" if $schema_path; |
43
|
4
|
|
|
|
|
535
|
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__ |