tfexec: Improve error message for incompatible version (#191)
diff --git a/tfexec/exit_errors.go b/tfexec/exit_errors.go index 5596fa2..359e6ad 100644 --- a/tfexec/exit_errors.go +++ b/tfexec/exit_errors.go
@@ -243,5 +243,16 @@ } func (e *ErrTFVersionMismatch) Error() string { - return "terraform core version not supported by configuration" + version := "version" + if e.TFVersion != "" { + version = e.TFVersion + } + + requirement := "" + if e.Constraint != "" { + requirement = fmt.Sprintf(" (%s required)", e.Constraint) + } + + return fmt.Sprintf("terraform %s not supported by configuration%s", + version, requirement) }