class

Krikri::YamlSyntaxError

Inherits Exception < Reference < Object

Represents an entire playbook A YAML syntax error in a playbook, carrying enough structure to be rendered the way real ansible-playbook renders one (see #render). Previously this was a bare raise "Invalid YAML in ...", which lost the position and printed nothing like real Ansible's output.

Constants

COLON_DETAIL = "mapping values are not allowed in this context"

libyaml's own wording for the single most common playbook YAML mistake (an unquoted value containing ": "), mapped to real Ansible's phrasing and its worked-example hint. Any other error keeps our YAML library's own message - real Ansible's prose for those comes from ITS parser and cannot be reproduced verbatim.

COLON_MESSAGE = "Colons in unquoted values must be followed by a non-space character."
TAB_DETAIL = "found a tab character"
TAB_MESSAGE = "Tabs are usually invalid in YAML."
TRUNCATED_NOTE = "(source not shown: file truncated)"

Constructors

new(path : String, content : String, cause : YAML::ParseException)
Source

Class methods

normalize(message : String) : String

Crystal's YAML::ParseException message inlines the position and puts libyaml's CONTEXT last:

"did not find expected ',' or ']' at line 3, column 1, while parsing a flow sequence"

real Ansible renders libyaml's two halves the other way round, capitalized and full-stopped:

"While parsing a flow sequence did not find expected ',' or ']'."

(verified against ansible-core 2.19.4). Reorder to match.

Source

Instance methods

colon_error?
Source
column
Source
detail
Source
line
Source
path
Source
render

Real ansible-playbook's own layout, verified against ansible-core 2.19.4:

[ERROR]: YAML parsing failed: <message>
Origin: /abs/path.yml:1:9

1 this: is: bad: [
          ^ column 9
Source
tab_error?
Source