19
// It also logs `staticMessage` using softassert.Fail.
20
// `optionalErr` is added as a tag with key "softassert-error-details".
21
>
func UnexpectedInternalErr(logger log.Logger, staticMessage string, optionalErr error, tags ...tag.Tag) error {
serviceerror.go
22
>
// (1) trigger softassert
23
>
combinedTags := tags
24
>
if optionalErr != nil {
25
>
combinedTags = append([]tag.Tag{tag.NewErrorTag(errorDetailsTagName, optionalErr)}, tags...)
26
>
}
27
>
Fail(logger, staticMessage, combinedTags...)
28
>
29
>
// (2) return serviceerror
30
>
message := staticMessage
31
>
if optionalErr != nil {
32
>
message = fmt.Sprintf("%s: %s", staticMessage, optionalErr)
33
>
}
34
>
return serviceerror.NewInternal(message)
35
}
36