func ToObjectResolutionDetail()

in pkg/confidence/utils.go [301:329]


func ToObjectResolutionDetail(res InterfaceResolutionDetail, defaultValue interface{}) InterfaceResolutionDetail {
	if res.ResolutionDetail.Reason == TargetingMatchReason {
		v, ok := res.Value.(interface{})
		if ok {
			return InterfaceResolutionDetail{
				Value:            v,
				ResolutionDetail: res.ResolutionDetail,
			}
		}

		err := NewTypeMismatchResolutionError("Unable to convert response property to float")

		return InterfaceResolutionDetail{
			Value: defaultValue,
			ResolutionDetail: ResolutionDetail{
				Variant:      "",
				Reason:       ErrorReason,
				ErrorCode:    err.code,
				ErrorMessage: err.message,
				FlagMetadata: nil,
			},
		}
	}

	return InterfaceResolutionDetail{
		Value:            defaultValue,
		ResolutionDetail: res.ResolutionDetail,
	}
}