Skip to content

Commit

Permalink
Merge pull request #374 from Hkesd/feature/errors-append-metadata
Browse files Browse the repository at this point in the history
errors add appendMd methods
  • Loading branch information
askuy authored Mar 28, 2024
2 parents e9133d2 + a544ed9 commit bec17ee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/eerrors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Error interface {
WithMd(map[string]string) Error
WithMessage(string) Error
WithMsg(string) Error
AppendMd(map[string]string) Error
}

const (
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit bec17ee

Please sign in to comment.