Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors add appendMd methods #374

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
return err
}

// AppendMd appends metadata to current EgoError
func (x *EgoError) AppendMd(md map[string]string) Error {
err := proto.Clone(x).(*EgoError)

Check warning on line 105 in core/eerrors/errors.go

View check run for this annotation

Codecov / codecov/patch

core/eerrors/errors.go#L105

Added line #L105 was not covered by tests
for k, v := range md {
err.Metadata[k] = v

Check warning on line 107 in core/eerrors/errors.go

View check run for this annotation

Codecov / codecov/patch

core/eerrors/errors.go#L107

Added line #L107 was not covered by tests
}
return err

Check warning on line 109 in core/eerrors/errors.go

View check run for this annotation

Codecov / codecov/patch

core/eerrors/errors.go#L109

Added line #L109 was not covered by tests
}

// New returns an error object for the code, message.
func New(code int, reason, message string) *EgoError {
return &EgoError{
Expand Down
Loading