Skip to content

Commit 8f6b134

Browse files
Mikael Olenfalkapparentlymart
authored andcommitted
Return PosError instead of error in more cases
1 parent 392dba7 commit 8f6b134

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

hcl/parser/parser.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,12 @@ func (p *Parser) objectItem() (*ast.ObjectItem, error) {
197197
keyStr = append(keyStr, k.Token.Text)
198198
}
199199

200-
return nil, fmt.Errorf(
201-
"key '%s' expected start of object ('{') or assignment ('=')",
202-
strings.Join(keyStr, " "))
200+
return nil, &PosError{
201+
Pos: p.tok.Pos,
202+
Err: fmt.Errorf(
203+
"key '%s' expected start of object ('{') or assignment ('=')",
204+
strings.Join(keyStr, " ")),
205+
}
203206
}
204207

205208
// do a look-ahead for line comment
@@ -319,7 +322,10 @@ func (p *Parser) objectType() (*ast.ObjectType, error) {
319322

320323
// No error, scan and expect the ending to be a brace
321324
if tok := p.scan(); tok.Type != token.RBRACE {
322-
return nil, fmt.Errorf("object expected closing RBRACE got: %s", tok.Type)
325+
return nil, &PosError{
326+
Pos: tok.Pos,
327+
Err: fmt.Errorf("object expected closing RBRACE got: %s", tok.Type),
328+
}
323329
}
324330

325331
o.List = l

0 commit comments

Comments
 (0)