File Coverage

blib/lib/YAML/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::Error;
2              
3 4     4   93149 use YAML::Mo;
  4         8  
  4         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 46     46 0 56 my $self = shift;
15 46         74 my $output = 'YAML ' . $self->type . ': ';
16 46         79 my $code = $self->code;
17 46 100       104 if ($error_messages->{$code}) {
18 44         54 $code = sprintf($error_messages->{$code}, @{$self->arguments});
  44         65  
19             }
20 46         111 $output .= $code . "\n";
21              
22 46 50       76 $output .= ' Code: ' . $self->code . "\n"
23             if defined $self->code;
24 46 100       75 $output .= ' Line: ' . $self->line . "\n"
25             if defined $self->line;
26 46 100       83 $output .= ' Document: ' . $self->document . "\n"
27             if defined $self->document;
28 46         4412 return $output;
29             }
30              
31             sub error_messages {
32 0     0 0   $error_messages;
33             }
34              
35             %$error_messages = map {s/^\s+//;s/\\n/\n/;$_} split "\n", <<'...';
36             YAML_PARSE_ERR_BAD_CHARS
37             Invalid characters in stream. This parser only supports printable ASCII
38             YAML_PARSE_ERR_BAD_MAJOR_VERSION
39             Can't parse a %s document with a 1.0 parser
40             YAML_PARSE_WARN_BAD_MINOR_VERSION
41             Parsing a %s document with a 1.0 parser
42             YAML_PARSE_WARN_MULTIPLE_DIRECTIVES
43             '%s directive used more than once'
44             YAML_PARSE_ERR_TEXT_AFTER_INDICATOR
45             No text allowed after indicator
46             YAML_PARSE_ERR_NO_ANCHOR
47             No anchor for alias '*%s'
48             YAML_PARSE_ERR_NO_SEPARATOR
49             Expected separator '---'
50             YAML_PARSE_ERR_SINGLE_LINE
51             Couldn't parse single line value
52             YAML_PARSE_ERR_BAD_ANCHOR
53             Invalid anchor
54             YAML_DUMP_ERR_INVALID_INDENT
55             Invalid Indent width specified: '%s'
56             YAML_LOAD_USAGE
57             usage: YAML::Load($yaml_stream_scalar)
58             YAML_PARSE_ERR_BAD_NODE
59             Can't parse node
60             YAML_PARSE_ERR_BAD_EXPLICIT
61             Unsupported explicit transfer: '%s'
62             YAML_DUMP_USAGE_DUMPCODE
63             Invalid value for DumpCode: '%s'
64             YAML_LOAD_ERR_FILE_INPUT
65             Couldn't open %s for input:\n%s
66             YAML_DUMP_ERR_FILE_CONCATENATE
67             Can't concatenate to YAML file %s
68             YAML_DUMP_ERR_FILE_OUTPUT
69             Couldn't open %s for output:\n%s
70             YAML_DUMP_ERR_FILE_OUTPUT_CLOSE
71             Error closing %s:\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 '%s' 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::Warning;
188              
189             our @ISA = 'YAML::Error';
190              
191             1;