-
Notifications
You must be signed in to change notification settings - Fork 0
ARTESCA-16170: Initialize an error library for golang #1
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
Conversation
bb1c3f2 to
923b484
Compare
| func (e *Error) WithDetail(detail string) *Error { | ||
| e.Details = append(e.Details, strings.TrimSuffix(detail, ".")) | ||
|
|
||
| return e | ||
| } |
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.
I think if this is our functional replacement for Wrap, we should add a
WithDetailf function
func (e *Error) WithDetailf(format string, args ...any) *Error {
return e.WithDetails(fmt.Sprintf(string, args))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.
done
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.
To me this doesn't replace wrap.
This have to be called on an already created error from the lib, which defy the purpose of wrapping in the first place IMHO
Looking at the previous implementation, the logic difference is clear:
func Wrap(err error, message string) error {
if err == nil {
return nil
}
err = &withMessage{
cause: err,
msg: message,
}
return &withStack{
err,
callers(),
}
}But I'm all in for @eg-ayoub's suggestion
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.
I see it from a end purpose point of view,
wrap and wrapf supplement the output of Error()
and with the details object, that purpose is fulfilled, cf. Error() lines 154 to 161
923b484 to
f6625a6
Compare
| func (e *Error) WithDetail(detail string) *Error { | ||
| e.Details = append(e.Details, strings.TrimSuffix(detail, ".")) | ||
|
|
||
| return e | ||
| } |
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.
To me this doesn't replace wrap.
This have to be called on an already created error from the lib, which defy the purpose of wrapping in the first place IMHO
Looking at the previous implementation, the logic difference is clear:
func Wrap(err error, message string) error {
if err == nil {
return nil
}
err = &withMessage{
cause: err,
msg: message,
}
return &withStack{
err,
callers(),
}
}But I'm all in for @eg-ayoub's suggestion
b8e70d1 to
378e446
Compare
Signed-off-by: Anthony TREUILLIER <anthony.treuillier@scality.com>
378e446 to
b993ac2
Compare
No description provided.