1package entity
2
3import (
4 "fmt"
5 "strings"
6)
7
8type ErrMultipleMatch struct {
9 entityType string
10 Matching []Id
11}
12
13func NewErrMultipleMatch(entityType string, matching []Id) *ErrMultipleMatch {
14 return &ErrMultipleMatch{entityType: entityType, Matching: matching}
15}
16
17func (e ErrMultipleMatch) Error() string {
18 matching := make([]string, len(e.Matching))
19
20 for i, match := range e.Matching {
21 matching[i] = match.String()
22 }
23
24 return fmt.Sprintf("Multiple matching %s found:\n%s",
25 e.entityType,
26 strings.Join(matching, "\n"))
27}
28
29func IsErrMultipleMatch(err error) bool {
30 _, ok := err.(*ErrMultipleMatch)
31 return ok
32}