aboutsummaryrefslogtreecommitdiffstats
path: root/entity/err.go
blob: 7022305cf252e3c1fdd2cce8fff6c43cf7450118 (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
package entity

import (
	"fmt"
	"strings"
)

type ErrMultipleMatch struct {
	entityType string
	Matching   []Id
}

func NewErrMultipleMatch(entityType string, matching []Id) *ErrMultipleMatch {
	return &ErrMultipleMatch{entityType: entityType, Matching: matching}
}

func (e ErrMultipleMatch) Error() string {
	matching := make([]string, len(e.Matching))

	for i, match := range e.Matching {
		matching[i] = match.String()
	}

	return fmt.Sprintf("Multiple matching %s found:\n%s",
		e.entityType,
		strings.Join(matching, "\n"))
}