This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 62aac2c4 [operator] Refinement of utilization error
62aac2c4 is described below
commit 62aac2c4d8f81a9fe4e1996cb907a045de69a855
Author: mfordjody <[email protected]>
AuthorDate: Thu Dec 12 20:05:52 2024 +0800
[operator] Refinement of utilization error
---
operator/pkg/util/errs.go | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/operator/pkg/util/errs.go b/operator/pkg/util/errs.go
index d80ca1c2..15290087 100644
--- a/operator/pkg/util/errs.go
+++ b/operator/pkg/util/errs.go
@@ -10,6 +10,50 @@ func (e Errors) Error() string {
return ToString(e, defaultSeparator)
}
+func ToString(errors []error, separator string) string {
+ var out string
+ for i, e := range errors {
+ if e == nil {
+ continue
+ }
+ if i != 0 {
+ out += separator
+ }
+ out += e.Error()
+ }
+ return out
+}
+
func (e Errors) ToString() {
}
+
+func NewErrs(err error) Errors {
+ if err == nil {
+ return nil
+ }
+ return []error{err}
+}
+
+func AppendErr(errors []error, err error) Errors {
+ if err == nil {
+ if len(errors) == 0 {
+ return nil
+ }
+ return errors
+ }
+ return append(errors, err)
+}
+
+func AppendErrs(errors []error, newErrs []error) Errors {
+ if len(newErrs) == 0 {
+ return errors
+ }
+ for _, e := range newErrs {
+ errors = AppendErr(errors, e)
+ }
+ if len(errors) == 0 {
+ return nil
+ }
+ return errors
+}