-
Notifications
You must be signed in to change notification settings - Fork 2
/
error.go
34 lines (29 loc) · 1.02 KB
/
error.go
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
29
30
31
32
33
34
package property
import (
"fmt"
"reflect"
"strings"
)
var (
ErrorPredicate = fmt.Errorf("predicate configuration error") // Property predicate is invalid
ErrorInputs = fmt.Errorf("inputs generator error") // Property input generator is invalid
ErrorPropertyConfig = fmt.Errorf("property configuration error") // Property returned an error
)
func inputMissmatchError(targets []reflect.Type, predicate reflect.Type) error {
expected := make([]string, len(targets))
for index, target := range targets {
expected[index] = target.String()
}
got := make([]string, predicate.NumIn())
for index := 0; index < predicate.NumIn(); index++ {
got[index] = predicate.In(index).String()
}
return fmt.Errorf(
"%w. %s", ErrorInputs,
fmt.Sprint(
fmt.Sprintln("property.Generator.Filter: predicate inputs do not match generator's targets, predicate inputs"),
fmt.Sprintf("Property Predicate: (%s)\n", strings.Join(expected, ", ")),
fmt.Sprintf("Filter Predicate: (%s)\n", strings.Join(got, ", ")),
),
)
}