Layer generators error return type fix (#14526)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2e1dc79a03
Коммит
744ec281d2
@@ -18,7 +18,15 @@ import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const OPEN_TRACING_PARAMS_MARKER = "@openTracingParams"
|
||||
const (
|
||||
OPEN_TRACING_PARAMS_MARKER = "@openTracingParams"
|
||||
APP_ERROR_TYPE = "*model.AppError"
|
||||
ERROR_TYPE = "error"
|
||||
)
|
||||
|
||||
func isError(typeName string) bool {
|
||||
return strings.Contains(typeName, APP_ERROR_TYPE) || strings.Contains(typeName, ERROR_TYPE)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := buildTimerLayer(); err != nil {
|
||||
@@ -212,7 +220,7 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
||||
},
|
||||
"errorToBoolean": func(results []string) string {
|
||||
for i, typeName := range results {
|
||||
if typeName == "*model.AppError" {
|
||||
if isError(typeName) {
|
||||
return fmt.Sprintf("resultVar%d == nil", i)
|
||||
}
|
||||
}
|
||||
@@ -220,7 +228,7 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
||||
},
|
||||
"errorPresent": func(results []string) bool {
|
||||
for _, typeName := range results {
|
||||
if typeName == "*model.AppError" {
|
||||
if isError(typeName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -228,7 +236,7 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
||||
},
|
||||
"errorVar": func(results []string) string {
|
||||
for i, typeName := range results {
|
||||
if typeName == "*model.AppError" {
|
||||
if isError(typeName) {
|
||||
return fmt.Sprintf("resultVar%d", i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1495,6 +1495,11 @@ func (s *OpenTracingLayerChannelStore) MigratePublicChannels() error {
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := s.ChannelStore.MigratePublicChannels()
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
|
||||
@@ -1401,7 +1401,7 @@ func (s *TimerLayerChannelStore) MigratePublicChannels() error {
|
||||
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
||||
if s.Root.Metrics != nil {
|
||||
success := "false"
|
||||
if true {
|
||||
if resultVar0 == nil {
|
||||
success = "true"
|
||||
}
|
||||
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.MigratePublicChannels", success, elapsed)
|
||||
|
||||
Ссылка в новой задаче
Block a user