Skip to content

Commit

Permalink
refactor addErrMultiLoc
Browse files Browse the repository at this point in the history
  • Loading branch information
neelance committed May 23, 2017
1 parent ee5e1c3 commit d39712c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ type context struct {
}

func (c *context) addErr(loc errors.Location, rule string, format string, a ...interface{}) {
c.addErrMultiLoc([]errors.Location{loc}, rule, format, a...)
}

func (c *context) addErrMultiLoc(locs []errors.Location, rule string, format string, a ...interface{}) {
c.errs = append(c.errs, &errors.QueryError{
Message: fmt.Sprintf(format, a...),
Locations: []errors.Location{loc},
Locations: locs,
Rule: rule,
})
}
Expand Down Expand Up @@ -309,11 +313,7 @@ func (c *context) validateName(set nameSet, name lexer.Ident, rule string, kind

func (c *context) validateNameCustomMsg(set nameSet, name lexer.Ident, rule string, msg func() string) {
if loc, ok := set[name.Name]; ok {
c.errs = append(c.errs, &errors.QueryError{
Message: msg(),
Locations: []errors.Location{loc, name.Loc},
Rule: rule,
})
c.addErrMultiLoc([]errors.Location{loc, name.Loc}, rule, msg())
return
}
set[name.Name] = name.Loc
Expand Down

0 comments on commit d39712c

Please sign in to comment.