diff --git a/nomad/structs/funcs.go b/nomad/structs/funcs.go index bc57c2804..751befd65 100644 --- a/nomad/structs/funcs.go +++ b/nomad/structs/funcs.go @@ -18,10 +18,6 @@ import ( // MergeMultierrorWarnings takes job warnings and canonicalize warnings and // merges them into a returnable string. Both the errors may be nil. func MergeMultierrorWarnings(warnings ...error) string { - if len(warnings) == 0 { - return "" - } - var warningMsg multierror.Error for _, warn := range warnings { if warn != nil { @@ -29,6 +25,10 @@ func MergeMultierrorWarnings(warnings ...error) string { } } + if len(warningMsg.Errors) == 0 { + return "" + } + // Set the formatter warningMsg.ErrorFormat = warningsFormatter return warningMsg.Error()