to wrap it using something like fmt.Errorf but I don't want the previous error to show on the string when doing .Error() method. What can I do?
you want to wrap but you don't want to wrap? :D
I want to wrap the error without concatenating the output strings
what's the point then?
Create your own error struct and implement the Error interface on it
I did, I was looking for something on the stdlib that I might had missed
hiding errors when wrapping would be all sorts of wrong. Why would you hide it?
an external function returns un ugly message that I don't want to display to the end user, I want to wrap it into an error wich still say where it went wrong but preserving the type of the original error by wrapping it
use a custom error type :)
Is what I did, as I said I just wanted to see if there was something else type errorWrapper struct { wrapped error message string } func wrapError(out string, err error) error { return errorWrapper{err, out} } func (e errorWrapper) Error() string { return e.message } func (e errorWrapper) Unwrap() error { return e.wrapped }
I use it only internally 🤔
I had a team mate in apex legends a few minutes ago with your name, toxic AF. Unrelated but amusing none the less 😂
Never played apex so yhea weird 😅
You can create your own error container
Yep something like this would work
Обсуждают сегодня