errors
errors copied to clipboard
Error details that created with `errors.NewWithDetails` are lost after it combined using `errors.Combine`
Code to reproduce
errWithDetail := errors.NewWithDetails(
"errorMessage",
"key", "value",
)
errOther := errors.New("Something")
errors.GetDetails(errWithDetail) // [key, value] -> detail exists
errors.GetDetails(errors.Combine(errWithDetail, errOther) // [] -> prints empty slice
// also happened here
errors.Append(errWithDetail, errOther) // []
Is this expected?
Good question...I'd say yeah, this makes sense. Not returning details is somewhat easier than resolving potentially conflicting ones.
Also, returning multiple errors should be relatively rare, so in those cases you might want to unpack errors and handle them separately. If you use an error handler, you could actually implement a middleware that unpacks these errors for you and passes them to the underlying handler one by one.