diagnostics

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 15 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 AddExtra added in v0.4.2

func AddExtra(diag *hcl.Diagnostic, extra any)

Adds extra without replacing existing extras.

func AddExtraIfMissing added in v0.4.2

func AddExtraIfMissing[T any](d Diag, extra T)

Adds an extra if no extra with the same type is present.

func DiagnosticExtra added in v0.4.2

func DiagnosticExtra[T any](diag *hcl.Diagnostic) (_ T, _ bool)

func DiagnosticsExtra added in v0.4.2

func DiagnosticsExtra[T any](diags Diag) (val T, found bool)

func FindByExtra

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

func PrintDiags

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

Types

type Diag

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

func FromErr

func FromErr(err error, summary string) (diags Diag)

func FromErrSubj

func FromErrSubj(err error, summary string, subject *hcl.Range) (diags 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) AddExtra added in v0.4.2

func (d Diag) AddExtra(extra any)

Adds extra without replacing existing extras.

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) DefaultSubject added in v0.4.2

func (d *Diag) DefaultSubject(rng *hcl.Range)

Set the subject for diagnostics if it's not already specified.

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.

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 cty.Path

func NewPathExtra added in v0.4.2

func NewPathExtra(p cty.Path) PathExtra

func (PathExtra) String added in v0.4.2

func (p PathExtra) String() string

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