diagnostics

package
v0.4.3-final-apache Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RepeatedError = &hcl.Diagnostic{
	Severity: hcl.DiagError,
	Extra:    repeatedError{},
}

Invisible to user error, typically used to signal that the initial block evaluation has failed (and already has reported its errors to user).

Functions

func DiagnosticsGetExtra

func DiagnosticsGetExtra[T any](diags Diag) (extra T, found bool)

DiagnosticsGetExtra finds the first extra of type T in the slice of provided diagnostics

func FindByExtra

func FindByExtra[T any](diags Diag) *hcl.Diagnostic

func GetExtra

func GetExtra[T any](diag *hcl.Diagnostic) (extra T, found bool)

GetExtra finds extra of type T in a provided diagnostic

func PrintDiags

func PrintDiags(output io.Writer, diags []*hcl.Diagnostic, fileMap map[string]*hcl.File, colorize bool)

Types

type DefaultSubject

type DefaultSubject hcl.Range

Set Subject field if empty

func (DefaultSubject) Refine

func (ds DefaultSubject) Refine(diags Diag)

type DefaultSummary

type DefaultSummary string

Set Summary field if empty

func (DefaultSummary) Refine

func (ds DefaultSummary) Refine(diags Diag)

type Diag

type Diag hcl.Diagnostics // Diagnostics does implement error interface, but is not, itself, an error.

func FromErr

func FromErr(err error, refiners ...Refiner) (diags Diag)

Turns error into Diag.

func FromHcl

func FromHcl(diag *hcl.Diagnostic) Diag

func (*Diag) Add

func (d *Diag) Add(summary, detail string)

Add new diagnostic error.

func (*Diag) AddWarn added in v0.4.2

func (d *Diag) AddWarn(summary, detail string)

Add new diagnostic warning.

func (*Diag) Append

func (d *Diag) Append(diag *hcl.Diagnostic) (addedErrors bool)

Appends diag to diagnostics, returns true if the just-appended diagnostic is an error.

func (*Diag) AppendErr

func (d *Diag) AppendErr(err error, summary string) (haveAddedErrors bool)

Creates diagnostic and appends it if err != nil.

func (Diag) Error

func (d Diag) Error() string

func (*Diag) Extend

func (d *Diag) Extend(diags []*hcl.Diagnostic) (haveAddedErrors bool)

Appends all diags to diagnostics, returns true if the just-appended diagnostics contain an error.

func (Diag) HasErrors

func (d Diag) HasErrors() bool

HasErrors returns true if the receiver contains any diagnostics of severity DiagError.

func (Diag) Refine

func (d Diag) Refine(refiners ...Refiner) Diag

Applies refiners to diagnostics, returns the input diagnostics for chaining.

type GoJQError added in v0.4.2

type GoJQError struct {
	Err   error
	Query string
}

Attach this as an .Extra on diagnostic to enhance the error message for gojq errors. Diagnostic must include Subject pointing to the query expression.

type PathExtra added in v0.4.2

type PathExtra struct {
	// contains filtered or unexported fields
}

func AddPath

func AddPath(p cty.Path) *PathExtra

Stores path in hcl.Diagnostic.Extra, or via Diag.Refine. Add path, prepending if any already exist.

func DefaultPath

func DefaultPath(p cty.Path) *PathExtra

Adds path to diagnostics that do not have a path already

func (*PathExtra) Refine

func (p *PathExtra) Refine(diags Diag)

Refine implements DiagnosticRefiner.

func (*PathExtra) String added in v0.4.2

func (p *PathExtra) String() string

type Refiner

type Refiner interface {
	Refine(diags Diag)
}

func AddExtra added in v0.4.2

func AddExtra(extra any) Refiner

Adds an extra without replacing existing extras.

type TracebackExtra added in v0.4.2

type TracebackExtra = *tracebackExtra

func NewTracebackExtra added in v0.4.2

func NewTracebackExtra() TracebackExtra

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL