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)
| 40 | // produced during a transform, ensuring that they will be seen when the |
| 41 | // caller eventually extracts content from the returned body. |
| 42 | func 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 | |
| 54 | type diagBody struct { |
| 55 | Diags hcl.Diagnostics |