From 99b5c58d43137bd9f6503788a55484327b0c531f Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Mon, 12 Aug 2019 16:12:14 +0200 Subject: finish the refactoring for the dedicated identifier type --- bug/bug.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'bug/bug.go') diff --git a/bug/bug.go b/bug/bug.go index d22a2f5e..eb0337a4 100644 --- a/bug/bug.go +++ b/bug/bug.go @@ -29,18 +29,12 @@ const editClockEntryPattern = "edit-clock-%d" var ErrBugNotExist = errors.New("bug doesn't exist") -type ErrMultipleMatch struct { - Matching []entity.Id +func NewErrMultipleMatchBug(matching []entity.Id) *entity.ErrMultipleMatch { + return entity.NewErrMultipleMatch("bug", 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 bug found:\n%s", strings.Join(matching, "\n")) +func NewErrMultipleMatchOp(matching []entity.Id) *entity.ErrMultipleMatch { + return entity.NewErrMultipleMatch("operation", matching) } var _ Interface = &Bug{} @@ -100,7 +94,7 @@ func FindLocalBug(repo repository.ClockedRepo, prefix string) (*Bug, error) { } if len(matching) > 1 { - return nil, ErrMultipleMatch{Matching: matching} + return nil, NewErrMultipleMatchBug(matching) } return ReadLocalBug(repo, matching[0]) -- cgit