MCPcopy
hub / github.com/hashicorp/hcl / BodyWithDiagnostics

Function BodyWithDiagnostics

ext/transform/error.go:42–52  ·  view source on GitHub ↗

BodyWithDiagnostics returns a hcl.Body that wraps another hcl.Body and emits the given diagnostics for any content-extraction method. Unlike the result of NewErrorBody, a body with diagnostics still runs the extraction actions on the underlying body if (and only if) the given diagnostics do not con

(body hcl.Body, diags hcl.Diagnostics)

Source from the content-addressed store, hash-verified

40// produced during a transform, ensuring that they will be seen when the
41// caller eventually extracts content from the returned body.
42func BodyWithDiagnostics(body hcl.Body, diags hcl.Diagnostics) hcl.Body {
43 if len(diags) == 0 {
44 // nothing to do!
45 return body
46 }
47
48 return diagBody{
49 Diags: diags,
50 Wrapped: body,
51 }
52}
53
54type diagBody struct {
55 Diags hcl.Diagnostics

Callers 1

TestDeepFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDeepFunction · 0.68