Browse Source

basic: cleanup using parser.NewError()

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/8/head
Alejandro Mery 1 year ago
parent
commit
d316031c44
  1. 17
      basic/error.go

17
basic/error.go

@ -4,6 +4,7 @@ import (
"errors" "errors"
"asciigoat.org/core/lexer" "asciigoat.org/core/lexer"
"asciigoat.org/ini/parser"
) )
var ( var (
@ -11,23 +12,11 @@ var (
) )
func newErrInvalidToken(t *token) *lexer.Error { func newErrInvalidToken(t *token) *lexer.Error {
err := &lexer.Error{ return parser.NewError(t.pos, t.value, "", errInvalidToken)
Line: t.pos.Line,
Column: t.pos.Column,
Content: t.value,
Err: errInvalidToken,
}
return err
} }
func (dec *decoder) OnError(pos lexer.Position, content string, err error) error { func (dec *decoder) OnError(pos lexer.Position, content string, err error) error {
err = &lexer.Error{ err = parser.NewError(pos, content, "", err)
Line: pos.Line,
Column: pos.Column,
Content: content,
Err: err,
}
dec.executeFinal() dec.executeFinal()
return err return err
} }

Loading…
Cancel
Save