From ae68cf17058e0e0103b01b432d35a76b90e54dd1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 16 Feb 2015 19:11:23 -0800 Subject: [PATCH] terraform: slightly better validation error messages --- terraform/graph_walk_context.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/terraform/graph_walk_context.go b/terraform/graph_walk_context.go index 304df02d2..f99ca60da 100644 --- a/terraform/graph_walk_context.go +++ b/terraform/graph_walk_context.go @@ -1,8 +1,10 @@ package terraform import ( + "fmt" "sync" + "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform/dag" ) @@ -104,9 +106,17 @@ func (w *ContextGraphWalker) ExitEvalTree( return err } - // Record the validation error - w.ValidationWarnings = append(w.ValidationWarnings, verr.Warnings...) - w.ValidationErrors = append(w.ValidationErrors, verr.Errors...) + for _, msg := range verr.Warnings { + w.ValidationWarnings = append( + w.ValidationWarnings, + fmt.Sprintf("%s: %s", dag.VertexName(v), msg)) + } + for _, e := range verr.Errors { + w.ValidationErrors = append( + w.ValidationErrors, + errwrap.Wrapf(fmt.Sprintf("%s: {{err}}", dag.VertexName(v)), e)) + } + return nil }