40
// It also logs `staticMessage` using softassert.Fail.
41
// `optionalErr` is added as a tag with key "softassert-error-details".
42
>
func UnexpectedDataLoss(logger log.Logger, staticMessage string, optionalErr error, tags ...tag.Tag) error {
serviceerror.go
43
>
// (1) trigger softassert
44
>
combinedTags := tags
45
>
if optionalErr != nil {
46
combinedTags = append([]tag.Tag{tag.NewErrorTag(errorDetailsTagName, optionalErr)}, tags...)
47
}
49
>
50
>
// (2) return serviceerror
51
>
message := staticMessage
52
>
if optionalErr != nil {
53
message = fmt.Sprintf("%s: %s", staticMessage, optionalErr)
54
}
56
}