line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# pyyaml/lib/yaml/error.py |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package YAML::Perl::Error; |
4
|
13
|
|
|
13
|
|
150
|
use strict; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
413
|
|
5
|
|
|
|
|
|
|
# use warnings; |
6
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
10998
|
use Error(); |
|
13
|
|
|
|
|
25924
|
|
|
13
|
|
|
|
|
594
|
|
8
|
|
|
|
|
|
|
$Error::Debug = 1; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package YAML::Perl::Mark; |
11
|
13
|
|
|
13
|
|
4788
|
use YAML::Perl::Base -base; |
|
13
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
118
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
field 'name'; |
14
|
|
|
|
|
|
|
field 'index'; |
15
|
|
|
|
|
|
|
field 'line'; |
16
|
|
|
|
|
|
|
field 'column'; |
17
|
|
|
|
|
|
|
field 'buffer'; |
18
|
|
|
|
|
|
|
field 'pointer'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_snippet { |
21
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
22
|
2
|
50
|
|
|
|
6
|
my $indent = @_ ? shift : 4; |
23
|
2
|
50
|
|
|
|
29
|
my $max_length = @_ ? shift : 75; |
24
|
2
|
50
|
|
|
|
80
|
if (not defined $self->buffer) { |
25
|
2
|
|
|
|
|
5
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
my $head = ''; |
28
|
0
|
|
|
|
|
|
my $start = $self->pointer; |
29
|
0
|
|
0
|
|
|
|
while ( |
30
|
|
|
|
|
|
|
$start > 0 and |
31
|
|
|
|
|
|
|
substr($self->buffer, $start - 1, 1) !~ /[\0\r\n\x85\x{2028}\x{2029}]/ |
32
|
|
|
|
|
|
|
) { |
33
|
0
|
|
|
|
|
|
$start--; |
34
|
0
|
0
|
|
|
|
|
if ($self->pointer - $start) { |
35
|
0
|
|
|
|
|
|
$head = ' ... '; |
36
|
0
|
|
|
|
|
|
$start += 5; |
37
|
0
|
|
|
|
|
|
last; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
my $tail = ''; |
41
|
0
|
|
|
|
|
|
my $end = $self->pointer; |
42
|
0
|
|
0
|
|
|
|
while ( |
43
|
|
|
|
|
|
|
$end < length($self->buffer) and |
44
|
|
|
|
|
|
|
substr($self->buffer, $start - 1, 1) !~ /[\0\r\n\x85\x{2028}\x{2029}]/ |
45
|
|
|
|
|
|
|
) { |
46
|
0
|
|
|
|
|
|
my $end += 1; |
47
|
0
|
0
|
|
|
|
|
if ($end - $self->pointer > $max_length / 2 - 1) { |
48
|
0
|
|
|
|
|
|
$tail = ' ... '; |
49
|
0
|
|
|
|
|
|
$end -= 5; |
50
|
0
|
|
|
|
|
|
last; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
my $snippet = substr($self->buffer, $start, $end - $start); |
54
|
|
|
|
|
|
|
return |
55
|
0
|
|
|
|
|
|
' ' x $indent . $head . $snippet . $tail . "\n" . |
56
|
|
|
|
|
|
|
' ' x ($indent + $self->pointer - $start + length($head)) . '^'; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use overload '""' => sub { |
60
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
61
|
2
|
|
|
|
|
7
|
my $snippet = $self->get_snippet(); |
62
|
2
|
|
|
|
|
61
|
my $where = sprintf |
63
|
|
|
|
|
|
|
'in "%s", line %d, column %d', |
64
|
|
|
|
|
|
|
$self->name, $self->line + 1, $self-> column + 1; |
65
|
2
|
50
|
|
|
|
8
|
if (defined $snippet) { |
66
|
0
|
|
|
|
|
0
|
$where += ":\n$snippet"; |
67
|
|
|
|
|
|
|
} |
68
|
2
|
|
|
|
|
9
|
return $where; |
69
|
13
|
|
|
13
|
|
92
|
}; |
|
13
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
193
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package YAML::Perl::Error; |
73
|
13
|
|
|
13
|
|
1170
|
use YAML::Perl::Base -base; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
79
|
|
74
|
13
|
|
|
13
|
|
81
|
use base 'Error::Simple'; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
962
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
*new = \&Error::Simple::new; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# sub throw { |
79
|
|
|
|
|
|
|
# my $self = shift; |
80
|
|
|
|
|
|
|
# local $Error::Depth = $Error::Depth + 1; |
81
|
|
|
|
|
|
|
# |
82
|
|
|
|
|
|
|
# # if we are not rethrow-ing then create the object to throw |
83
|
|
|
|
|
|
|
# $self = $self->new(@_) unless ref($self); |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# die $Error::THROWN = $self; |
86
|
|
|
|
|
|
|
# } |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
package YAML::Perl::Error::Marked; |
89
|
13
|
|
|
13
|
|
3686
|
use YAML::Perl::Error -base; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
126
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
field 'context'; |
92
|
|
|
|
|
|
|
field 'context_mark'; |
93
|
|
|
|
|
|
|
field 'problem'; |
94
|
|
|
|
|
|
|
field 'problem_mark'; |
95
|
|
|
|
|
|
|
field 'note'; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
use overload '""' => sub { |
98
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
99
|
0
|
|
|
|
|
0
|
my $lines = []; |
100
|
0
|
0
|
|
|
|
0
|
if (defined $self->context) { |
101
|
0
|
|
|
|
|
0
|
push @$lines, $self->context; |
102
|
|
|
|
|
|
|
} |
103
|
0
|
0
|
0
|
|
|
0
|
if ( |
|
|
|
0
|
|
|
|
|
104
|
|
|
|
|
|
|
$self->context_mark and ( |
105
|
|
|
|
|
|
|
not($self->problem) or |
106
|
|
|
|
|
|
|
not($self->problem_mark) or |
107
|
|
|
|
|
|
|
$self->context_mark->name ne $self->problem_mark->name or |
108
|
|
|
|
|
|
|
$self->context_mark->line != $self->problem_mark->line or |
109
|
|
|
|
|
|
|
$self->context_mark->column != $self->problem_mark->column |
110
|
|
|
|
|
|
|
) |
111
|
|
|
|
|
|
|
) { |
112
|
0
|
|
|
|
|
0
|
push @$lines, $self->context_mark . ""; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
0
|
|
|
|
0
|
if ($self->problem) { |
115
|
0
|
|
|
|
|
0
|
push @$lines, $self->problem; |
116
|
|
|
|
|
|
|
} |
117
|
0
|
0
|
|
|
|
0
|
if ($self->problem_mark) { |
118
|
0
|
|
|
|
|
0
|
push @$lines, $self->problem_mark . ""; |
119
|
|
|
|
|
|
|
} |
120
|
0
|
0
|
|
|
|
0
|
if ($self->note) { |
121
|
0
|
|
|
|
|
0
|
push @$lines, $self->note; |
122
|
|
|
|
|
|
|
} |
123
|
0
|
|
|
|
|
0
|
return join "\n", @$lines; |
124
|
13
|
|
|
13
|
|
71
|
}; |
|
13
|
|
|
|
|
37
|
|
|
13
|
|
|
|
|
197
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |