diff --git a/errors/consts.go b/errors/consts.go index 89c0bec..8802a46 100644 --- a/errors/consts.go +++ b/errors/consts.go @@ -14,6 +14,7 @@ const ( ErrTimeout = Error("TimeoutError") ErrNotFound = Error("NotFoundError") + ErrNotEmpty = Error("NotEmptyError") ErrDuplicateId = Error("DuplicateIdError") ErrInvalidStatus = Error("InvalidStatusError") ErrNotImplemented = Error("NotImplementedError") diff --git a/util/compare/syncresults.go b/util/compare/syncresults.go index 449caa9..3d56ab9 100644 --- a/util/compare/syncresults.go +++ b/util/compare/syncresults.go @@ -17,6 +17,8 @@ package compare import ( "fmt" "strings" + + "yunion.io/x/pkg/errors" ) type SyncResult struct { @@ -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() {