diff --git a/core/eerrors/errors.go b/core/eerrors/errors.go index a022bf31..24edc398 100644 --- a/core/eerrors/errors.go +++ b/core/eerrors/errors.go @@ -19,6 +19,7 @@ type Error interface { WithMd(map[string]string) Error WithMessage(string) Error WithMsg(string) Error + AppendMd(map[string]string) Error } const ( @@ -99,6 +100,15 @@ func (x *EgoError) WithMsg(msg string) Error { return err } +// AppendMd appends metadata to current EgoError +func (x *EgoError) AppendMd(md map[string]string) Error { + err := proto.Clone(x).(*EgoError) + for k, v := range md { + err.Metadata[k] = v + } + return err +} + // New returns an error object for the code, message. func New(code int, reason, message string) *EgoError { return &EgoError{