blob: b7b4a0cc73d2d81676b29d1c20c70500f88979af (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package model
import (
"errors"
"fmt"
)
type Body []any
var ErrInvalidType = errors.New("invalid type")
func (d Body) Execute(v Visitor) error {
for _, it := range d {
switch it := it.(type) {
case *Setting:
if err := v.VisitSetting(it.Key, it.Value); err != nil {
return err
}
case *Directive:
if err := v.VisitDirective(it.Name, it.Arguments, it.Body); err != nil {
return err
}
default:
return fmt.Errorf("%w: %t", ErrInvalidType, it)
}
}
return nil
}
|