build: return ErrorList type

Adds a very similar interface to go/scanner package for returning a list
of errors.

Updates #34
This commit is contained in:
Michael McLoughlin
2019-01-06 13:32:09 -08:00
parent b6576feee6
commit 07901bb91b
4 changed files with 80 additions and 19 deletions

View File

@@ -19,7 +19,7 @@ type Context struct {
file *avo.File
function *avo.Function
global *avo.Global
errs []error
errs ErrorList
reg.Collection
}
@@ -176,8 +176,7 @@ func (c *Context) activeglobal() *avo.Global {
}
func (c *Context) adderror(err error) {
e := exterr(err)
c.errs = append(c.errs, e)
c.errs.addext(err)
}
func (c *Context) adderrormessage(msg string) {
@@ -185,6 +184,6 @@ func (c *Context) adderrormessage(msg string) {
}
// Result returns the built file and any accumulated errors.
func (c *Context) Result() (*avo.File, []error) {
return c.file, c.errs
func (c *Context) Result() (*avo.File, error) {
return c.file, c.errs.Err()
}