From 6d2de15f0d8f69d0cd01c322a3ee7e7860dd4276 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Mon, 14 Aug 2023 15:42:10 -0400 Subject: [PATCH] Add ExpectedScalarOrMap error --- errors/parse.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/errors/parse.go b/errors/parse.go index b211917..867d13e 100644 --- a/errors/parse.go +++ b/errors/parse.go @@ -43,6 +43,11 @@ var ( ErrExpectedInt = fmt.Errorf( "%w: expected int value", ErrParse, ) + // ErrExpectedScalarOrMap indicates that we did not find an expected + // scalar or map field + ErrExpectedScalarOrMap = fmt.Errorf( + "%w: expected scalar or map field", ErrParse, + ) // ErrExpectedScalarOrSequence indicates that we did not find an expected // scalar or sequence of scalars field ErrExpectedScalarOrSequence = fmt.Errorf( @@ -126,6 +131,15 @@ func ExpectedScalarOrSequenceAt(node *yaml.Node) error { ) } +// ExpectedScalarOrMapAt returns an ErrExpectedScalarOrMap error annotated with +// the line/column of the supplied YAML node. +func ExpectedScalarOrMapAt(node *yaml.Node) error { + return fmt.Errorf( + "%w at line %d, column %d", + ErrExpectedScalarOrMap, node.Line, node.Column, + ) +} + // ExpectedTimeoutAt returns an ErrExpectedTimeout error annotated // with the line/column of the supplied YAML node. func ExpectedTimeoutAt(node *yaml.Node) error {