Skip to content

Commit

Permalink
fix: generate error
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito committed Apr 16, 2024
1 parent b89c998 commit 4b96224
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions errors/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
ErrTimeout = Error("TimeoutError")

ErrNotFound = Error("NotFoundError")
ErrNotEmpty = Error("NotEmptyError")
ErrDuplicateId = Error("DuplicateIdError")
ErrInvalidStatus = Error("InvalidStatusError")
ErrNotImplemented = Error("NotImplementedError")
Expand Down
11 changes: 11 additions & 0 deletions util/compare/syncresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package compare
import (
"fmt"
"strings"

"yunion.io/x/pkg/errors"
)

type SyncResult struct {
Expand Down Expand Up @@ -82,6 +84,15 @@ func (self *SyncResult) IsError() bool {
return self.errors != nil && len(self.errors) > 0
}

func (self *SyncResult) IsGenerateError() bool {
for _, err := range self.errors {
if e := errors.Cause(err); e != errors.ErrNotImplemented && e != errors.ErrNotSupported && e != errors.ErrNotEmpty {
return true
}
}
return false
}

func (self *SyncResult) Result() string {
msg := fmt.Sprintf("removed %d failed %d updated %d failed %d added %d failed %d", self.DelCnt, self.DelErrCnt, self.UpdateCnt, self.UpdateErrCnt, self.AddCnt, self.AddErrCnt)
if self.IsError() {
Expand Down

0 comments on commit 4b96224

Please # to comment.