Skip to content

Commit b079c5b

Browse files
committed
chore: add some more error context
1 parent e1ccd88 commit b079c5b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

extract/parameter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func optionalStringEnum[T ~string](block *terraform.Block, key string, def T, va
252252
tyAttr := block.GetAttribute(key)
253253
return "", &hcl.Diagnostic{
254254
Severity: hcl.DiagError,
255-
Summary: fmt.Sprintf("Invalid %q attribute", key),
255+
Summary: fmt.Sprintf("Invalid %q attribute for block %s", key, block.Label()),
256256
Detail: err.Error(),
257257
Subject: &(tyAttr.HCLAttribute().Range),
258258
//Context: &(block.HCLBlock().DefRange),
@@ -275,7 +275,7 @@ func requiredString(block *terraform.Block, key string) (string, *hcl.Diagnostic
275275

276276
diag := &hcl.Diagnostic{
277277
Severity: hcl.DiagError,
278-
Summary: fmt.Sprintf("Invalid %q attribute", key),
278+
Summary: fmt.Sprintf("Invalid %q attribute for block %s", key, block.Label()),
279279
Detail: fmt.Sprintf("Expected a string, got %q", typeName),
280280
Subject: &(tyAttr.HCLAttribute().Range),
281281
//Context: &(block.HCLBlock().DefRange),
@@ -393,7 +393,7 @@ func required(block *terraform.Block, keys ...string) hcl.Diagnostics {
393393
r := block.HCLBlock().Body.MissingItemRange()
394394
diags = diags.Append(&hcl.Diagnostic{
395395
Severity: hcl.DiagError,
396-
Summary: fmt.Sprintf("Missing required attribute %q", key),
396+
Summary: fmt.Sprintf("Missing required attribute %q for block %q", key, block.Label()),
397397
Detail: fmt.Sprintf("The %s attribute is required", key),
398398
Subject: &r,
399399
Extra: nil,

0 commit comments

Comments
 (0)