File Coverage

blib/lib/YAML/Old/Error.pm
Criterion Covered Total %
statement 14 15 93.3
branch 7 8 87.5
condition n/a
subroutine 2 3 66.6
pod 0 2 0.0
total 23 28 82.1


line stmt bran cond sub pod time code
1             package YAML::Old::Error;
2              
3 3     3   100198 use YAML::Old::Mo;
  3         7  
  3         23  
4              
5             has 'code';
6             has 'type' => default => sub {'Error'};
7             has 'line';
8             has 'document';
9             has 'arguments' => default => sub {[]};
10              
11             my ($error_messages, %line_adjust);
12              
13             sub format_message {
14 40     40 0 57 my $self = shift;
15 40         104 my $output = 'YAML ' . $self->type . ': ';
16 40         148 my $code = $self->code;
17 40 100       151 if ($error_messages->{$code}) {
18 39         66 $code = sprintf($error_messages->{$code}, @{$self->arguments});
  39         93  
19             }
20 40         131 $output .= $code . "\n";
21              
22 40 50       113 $output .= ' Code: ' . $self->code . "\n"
23             if defined $self->code;
24 40 100       125 $output .= ' Line: ' . $self->line . "\n"
25             if defined $self->line;
26 40 100       115 $output .= ' Document: ' . $self->document . "\n"
27             if defined $self->document;
28 40         7914 return $output;
29             }
30              
31             sub error_messages {
32 0     0 0   $error_messages;
33             }
34              
35             %$error_messages = map {s/^\s+//;$_} split "\n", <<'...';
36             YAML_PARSE_ERR_BAD_CHARS
37             Invalid characters in stream. This parser only supports printable ASCII
38             YAML_PARSE_ERR_NO_FINAL_NEWLINE
39             Stream does not end with newline character
40             YAML_PARSE_ERR_BAD_MAJOR_VERSION
41             Can't parse a %s document with a 1.0 parser
42             YAML_PARSE_WARN_BAD_MINOR_VERSION
43             Parsing a %s document with a 1.0 parser
44             YAML_PARSE_WARN_MULTIPLE_DIRECTIVES
45             '%s directive used more than once'
46             YAML_PARSE_ERR_TEXT_AFTER_INDICATOR
47             No text allowed after indicator
48             YAML_PARSE_ERR_NO_ANCHOR
49             No anchor for alias '*%s'
50             YAML_PARSE_ERR_NO_SEPARATOR
51             Expected separator '---'
52             YAML_PARSE_ERR_SINGLE_LINE
53             Couldn't parse single line value
54             YAML_PARSE_ERR_BAD_ANCHOR
55             Invalid anchor
56             YAML_DUMP_ERR_INVALID_INDENT
57             Invalid Indent width specified: '%s'
58             YAML_LOAD_USAGE
59             usage: YAML::Old::Load($yaml_stream_scalar)
60             YAML_PARSE_ERR_BAD_NODE
61             Can't parse node
62             YAML_PARSE_ERR_BAD_EXPLICIT
63             Unsupported explicit transfer: '%s'
64             YAML_DUMP_USAGE_DUMPCODE
65             Invalid value for DumpCode: '%s'
66             YAML_LOAD_ERR_FILE_INPUT
67             Couldn't open %s for input:\n%s
68             YAML_DUMP_ERR_FILE_CONCATENATE
69             Can't concatenate to YAML file %s
70             YAML_DUMP_ERR_FILE_OUTPUT
71             Couldn't open %s for output:\n%s
72             YAML_DUMP_ERR_NO_HEADER
73             With UseHeader=0, the node must be a plain hash or array
74             YAML_DUMP_WARN_BAD_NODE_TYPE
75             Can't perform serialization for node type: '%s'
76             YAML_EMIT_WARN_KEYS
77             Encountered a problem with 'keys':\n%s
78             YAML_DUMP_WARN_DEPARSE_FAILED
79             Deparse failed for CODE reference
80             YAML_DUMP_WARN_CODE_DUMMY
81             Emitting dummy subroutine for CODE reference
82             YAML_PARSE_ERR_MANY_EXPLICIT
83             More than one explicit transfer
84             YAML_PARSE_ERR_MANY_IMPLICIT
85             More than one implicit request
86             YAML_PARSE_ERR_MANY_ANCHOR
87             More than one anchor
88             YAML_PARSE_ERR_ANCHOR_ALIAS
89             Can't define both an anchor and an alias
90             YAML_PARSE_ERR_BAD_ALIAS
91             Invalid alias
92             YAML_PARSE_ERR_MANY_ALIAS
93             More than one alias
94             YAML_LOAD_ERR_NO_CONVERT
95             Can't convert implicit '%s' node to explicit '%s' node
96             YAML_LOAD_ERR_NO_DEFAULT_VALUE
97             No default value for '%s' explicit transfer
98             YAML_LOAD_ERR_NON_EMPTY_STRING
99             Only the empty string can be converted to a '%s'
100             YAML_LOAD_ERR_BAD_MAP_TO_SEQ
101             Can't transfer map as sequence. Non numeric key '%s' encountered.
102             YAML_DUMP_ERR_BAD_GLOB
103             '%s' is an invalid value for Perl glob
104             YAML_DUMP_ERR_BAD_REGEXP
105             '%s' is an invalid value for Perl Regexp
106             YAML_LOAD_ERR_BAD_MAP_ELEMENT
107             Invalid element in map
108             YAML_LOAD_WARN_DUPLICATE_KEY
109             Duplicate map key found. Ignoring.
110             YAML_LOAD_ERR_BAD_SEQ_ELEMENT
111             Invalid element in sequence
112             YAML_PARSE_ERR_INLINE_MAP
113             Can't parse inline map
114             YAML_PARSE_ERR_INLINE_SEQUENCE
115             Can't parse inline sequence
116             YAML_PARSE_ERR_BAD_DOUBLE
117             Can't parse double quoted string
118             YAML_PARSE_ERR_BAD_SINGLE
119             Can't parse single quoted string
120             YAML_PARSE_ERR_BAD_INLINE_IMPLICIT
121             Can't parse inline implicit value '%s'
122             YAML_PARSE_ERR_BAD_IMPLICIT
123             Unrecognized implicit value '%s'
124             YAML_PARSE_ERR_INDENTATION
125             Error. Invalid indentation level
126             YAML_PARSE_ERR_INCONSISTENT_INDENTATION
127             Inconsistent indentation level
128             YAML_LOAD_WARN_UNRESOLVED_ALIAS
129             Can't resolve alias *%s
130             YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP
131             No 'REGEXP' element for Perl regexp
132             YAML_LOAD_WARN_BAD_REGEXP_ELEM
133             Unknown element '%s' in Perl regexp
134             YAML_LOAD_WARN_GLOB_NAME
135             No 'NAME' element for Perl glob
136             YAML_LOAD_WARN_PARSE_CODE
137             Couldn't parse Perl code scalar: %s
138             YAML_LOAD_WARN_CODE_DEPARSE
139             Won't parse Perl code unless $YAML::LoadCode is set
140             YAML_EMIT_ERR_BAD_LEVEL
141             Internal Error: Bad level detected
142             YAML_PARSE_WARN_AMBIGUOUS_TAB
143             Amibiguous tab converted to spaces
144             YAML_LOAD_WARN_BAD_GLOB_ELEM
145             Unknown element '%s' in Perl glob
146             YAML_PARSE_ERR_ZERO_INDENT
147             Can't use zero as an indentation width
148             YAML_LOAD_WARN_GLOB_IO
149             Can't load an IO filehandle. Yet!!!
150             ...
151              
152             %line_adjust = map {($_, 1)}
153             qw(YAML_PARSE_ERR_BAD_MAJOR_VERSION
154             YAML_PARSE_WARN_BAD_MINOR_VERSION
155             YAML_PARSE_ERR_TEXT_AFTER_INDICATOR
156             YAML_PARSE_ERR_NO_ANCHOR
157             YAML_PARSE_ERR_MANY_EXPLICIT
158             YAML_PARSE_ERR_MANY_IMPLICIT
159             YAML_PARSE_ERR_MANY_ANCHOR
160             YAML_PARSE_ERR_ANCHOR_ALIAS
161             YAML_PARSE_ERR_BAD_ALIAS
162             YAML_PARSE_ERR_MANY_ALIAS
163             YAML_LOAD_ERR_NO_CONVERT
164             YAML_LOAD_ERR_NO_DEFAULT_VALUE
165             YAML_LOAD_ERR_NON_EMPTY_STRING
166             YAML_LOAD_ERR_BAD_MAP_TO_SEQ
167             YAML_LOAD_ERR_BAD_STR_TO_INT
168             YAML_LOAD_ERR_BAD_STR_TO_DATE
169             YAML_LOAD_ERR_BAD_STR_TO_TIME
170             YAML_LOAD_WARN_DUPLICATE_KEY
171             YAML_PARSE_ERR_INLINE_MAP
172             YAML_PARSE_ERR_INLINE_SEQUENCE
173             YAML_PARSE_ERR_BAD_DOUBLE
174             YAML_PARSE_ERR_BAD_SINGLE
175             YAML_PARSE_ERR_BAD_INLINE_IMPLICIT
176             YAML_PARSE_ERR_BAD_IMPLICIT
177             YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP
178             YAML_LOAD_WARN_BAD_REGEXP_ELEM
179             YAML_LOAD_WARN_REGEXP_CREATE
180             YAML_LOAD_WARN_GLOB_NAME
181             YAML_LOAD_WARN_PARSE_CODE
182             YAML_LOAD_WARN_CODE_DEPARSE
183             YAML_LOAD_WARN_BAD_GLOB_ELEM
184             YAML_PARSE_ERR_ZERO_INDENT
185             );
186              
187             package YAML::Old::Warning;
188              
189             our @ISA = 'YAML::Old::Error';
190              
191             1;