aboutsummaryrefslogtreecommitdiffstats
path: root/identity/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'identity/common.go')
-rw-r--r--identity/common.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/identity/common.go b/identity/common.go
index 2f2b9042..007e10d6 100644
--- a/identity/common.go
+++ b/identity/common.go
@@ -4,17 +4,14 @@ import (
"encoding/json"
"errors"
"fmt"
- "strings"
+
+ "github.com/MichaelMure/git-bug/entity"
)
var ErrIdentityNotExist = errors.New("identity doesn't exist")
-type ErrMultipleMatch struct {
- Matching []string
-}
-
-func (e ErrMultipleMatch) Error() string {
- return fmt.Sprintf("Multiple matching identities found:\n%s", strings.Join(e.Matching, "\n"))
+func NewErrMultipleMatch(matching []entity.Id) *entity.ErrMultipleMatch {
+ return entity.NewErrMultipleMatch("identity", matching)
}
// Custom unmarshaling function to allow package user to delegate
@@ -37,11 +34,11 @@ func UnmarshalJSON(raw json.RawMessage) (Interface, error) {
}
// Fallback on a legacy Bare identity
- var b Bare
+ b := &Bare{}
- err = json.Unmarshal(raw, &b)
+ err = json.Unmarshal(raw, b)
if err == nil && (b.name != "" || b.login != "") {
- return &b, nil
+ return b, nil
}
// abort if we have an error other than the wrong type