# README
Example: Parsing Run Errors
In this example, you'll use terraform to create a run with errors on HCP Terraform, then execute the command to read the plan log and filter it for errors. It's important to use Terraform to create the run, otherwise you will not get the structured log that this code example requires.
Instructions
- Change to the terraform directory, and run terraform init using Terraform 1.3+
cd terraform
TF_CLOUD_ORGANIZATION="yourorg" terraform init
- Apply the changes (You should see an error "Error making request" or similar)
TF_CLOUD_ORGANIZATION="yourorg" terraform apply
- Notice the run ID in the URL (it begins with "run-") and execute the example with the run ID as a flag:
cd ../
TFE_TOKEN="YOURTOKEN" go run main.go run-RUN_ID_FROM_URL_ABOVE
# Structs
Diagnostic represents a diagnostic type message from Terraform, which is how errors are usually represented.
DiagnosticRange represents the filename and position of the diagnostic subject.
For full decoding, see https://github.com/hashicorp/terraform/blob/main/internal/command/jsonformat/renderer.go.
Pos represents a position in the source code.