-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add errors helper package #1
Conversation
Signed-off-by: Emruz Hossain <[email protected]>
Signed-off-by: Emruz Hossain <[email protected]>
Signed-off-by: Emruz Hossain <[email protected]>
Signed-off-by: Emruz Hossain <[email protected]>
Signed-off-by: Emruz Hossain <[email protected]>
Signed-off-by: Emruz Hossain <[email protected]>
Signed-off-by: Emruz Hossain <[email protected]>
Signed-off-by: Emruz Hossain <[email protected]>
pkg/errors/errors.go
Outdated
return w.err | ||
} | ||
|
||
type Metadata []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not []any
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use []any
, this will allow following usage:
return errhelper.WithMetadata(err, errMetadata.Extend("key1", "value1"))
This will call WithMetadata()
function with only one key of type Metadata{"key1", "value1"}
which is not what we want.
Using []string
enforce that you have expanded the returned slice and use following instead:
return errhelper.WithMetadata(err, errMetadata.Extend("key1", "value1")...)
Signed-off-by: Emruz Hossain <[email protected]>
This PR adds helper package for wrapping errors with additional context.