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}
33
34// ErrOldFormatVersion indicate that the read data has a too old format.
35type ErrOldFormatVersion struct {
36 formatVersion uint
37}
38
39func NewErrOldFormatVersion(formatVersion uint) *ErrOldFormatVersion {
40 return &ErrOldFormatVersion{formatVersion: formatVersion}
41}
42
43func (e ErrOldFormatVersion) Error() string {
44 return fmt.Sprintf("outdated repository format %v, please use https://github.com/MichaelMure/git-bug-migration to upgrade", e.formatVersion)
45}
46
47// ErrNewFormatVersion indicate that the read data is too new for this software.
48type ErrNewFormatVersion struct {
49 formatVersion uint
50}
51
52func NewErrNewFormatVersion(formatVersion uint) *ErrNewFormatVersion {
53 return &ErrNewFormatVersion{formatVersion: formatVersion}
54}
55
56func (e ErrNewFormatVersion) Error() string {
57 return fmt.Sprintf("your version of git-bug is too old for this repository (version %v), please upgrade to the latest version", e.formatVersion)
58}