diag

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MPL-2.0 Imports: 9 Imported by: 300

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDiag added in v0.7.6

func CountDiag(d Diagnostic) uint64

func WrapError added in v0.8.7

func WrapError(err error) error

WrapError wraps error with the following string: "error at function_name[filename:line_number]: %w" if err is nil returns nil

Types

type BaseError

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

BaseError is a generic error returned when execution is run, satisfies Diagnostic interface

func NewBaseError

func NewBaseError(err error, dt Type, opts ...BaseErrorOption) *BaseError

NewBaseError creates a BaseError from given error, except the given error is a BaseError itself

func (BaseError) Description

func (e BaseError) Description() Description

func (BaseError) Error

func (e BaseError) Error() string

func (BaseError) Severity

func (e BaseError) Severity() Severity

func (BaseError) Type

func (e BaseError) Type() Type

func (BaseError) Unwrap added in v0.8.0

func (e BaseError) Unwrap() error

type BaseErrorOption added in v0.8.0

type BaseErrorOption func(*BaseError)

func WithDetails added in v0.8.0

func WithDetails(detail string, args ...interface{}) BaseErrorOption

func WithError added in v0.8.5

func WithError(err error) BaseErrorOption

func WithNoOverwrite added in v0.8.0

func WithNoOverwrite() BaseErrorOption

WithNoOverwrite sets the noOverwrite flag of BaseError, active for the duration of the application of options Deprecated: Prefer using WithOptionalSeverity on the opposite side instead

func WithOptionalSeverity added in v0.8.14

func WithOptionalSeverity(s Severity) BaseErrorOption

func WithResourceId added in v0.8.0

func WithResourceId(id []string) BaseErrorOption

func WithResourceName added in v0.8.0

func WithResourceName(resource string) BaseErrorOption

func WithSeverity added in v0.8.0

func WithSeverity(s Severity) BaseErrorOption

func WithSummary added in v0.8.0

func WithSummary(summary string, args ...interface{}) BaseErrorOption

func WithType added in v0.8.0

func WithType(dt Type) BaseErrorOption

type Countable added in v0.7.6

type Countable interface {
	Count() uint64
}

type Description

type Description struct {
	Resource   string
	ResourceID []string

	Summary string
	Detail  string
}

type Diagnostic

type Diagnostic interface {
	error
	Severity() Severity
	Type() Type
	Description() Description
}

func UnsquashDiag added in v0.9.0

func UnsquashDiag(d Diagnostic) Diagnostic

type Diagnostics

type Diagnostics []Diagnostic

func FromError added in v0.8.1

func FromError(err error, dt Type, opts ...BaseErrorOption) Diagnostics

FromError converts an error to Diagnostics, or return if it's already of type diagnostic(s). nil error returns nil value.

func (Diagnostics) Add

func (diags Diagnostics) Add(new ...interface{}) Diagnostics

func (Diagnostics) BySeverity added in v0.10.3

func (diags Diagnostics) BySeverity(sevs ...Severity) Diagnostics

BySeverity returns a subset of diagnostics matching the given severity.

func (Diagnostics) CountBySeverity added in v0.7.6

func (diags Diagnostics) CountBySeverity(sev Severity, includeSquashed bool) uint64

CountBySeverity returns number of diagnostics of the given severity. If includeSquashed is false, squashed diags are counted as a single diag.

func (Diagnostics) Error

func (diags Diagnostics) Error() string

func (Diagnostics) Errors

func (diags Diagnostics) Errors() uint64

func (Diagnostics) HasDiags

func (diags Diagnostics) HasDiags() bool

func (Diagnostics) HasErrors

func (diags Diagnostics) HasErrors() bool

func (Diagnostics) Len

func (diags Diagnostics) Len() int

func (Diagnostics) Less

func (diags Diagnostics) Less(i, j int) bool

func (Diagnostics) Redacted added in v0.8.6

func (diags Diagnostics) Redacted() Diagnostics

func (Diagnostics) Squash

func (diags Diagnostics) Squash() Diagnostics

Squash attempts to squash diagnostics

func (Diagnostics) Swap

func (diags Diagnostics) Swap(i, j int)

func (Diagnostics) Warnings

func (diags Diagnostics) Warnings() uint64

type FlatDiag

type FlatDiag struct {
	Err         string
	Resource    string
	ResourceID  []string
	Type        Type
	Severity    Severity
	Summary     string
	Description Description
}

FlatDiag is a structured diagnostic, usually can be used to create a json of diagnostics or testing.

type FlatDiags added in v0.10.3

type FlatDiags []FlatDiag

func FlattenDiags

func FlattenDiags(dd Diagnostics, skipDescription bool) FlatDiags

FlattenDiags converts Diagnostics to an array of FlatDiag

func (FlatDiags) Len added in v0.10.3

func (diags FlatDiags) Len() int

func (FlatDiags) Less added in v0.10.3

func (diags FlatDiags) Less(i, j int) bool

func (FlatDiags) Swap added in v0.10.3

func (diags FlatDiags) Swap(i, j int)

type Redactable

type Redactable interface {
	Redacted() Diagnostic
}

type RedactedDiagnostic

type RedactedDiagnostic struct {
	Diagnostic
	// contains filtered or unexported fields
}

func NewRedactedDiagnostic

func NewRedactedDiagnostic(vanilla, redacted Diagnostic) RedactedDiagnostic

func (RedactedDiagnostic) Redacted

func (p RedactedDiagnostic) Redacted() Diagnostic

type Severity

type Severity int

nolint:revive

const (
	// IGNORE severity is set for diagnostics that were ignored by the SDK
	IGNORE Severity = iota
	// WARNING severity are diagnostics that should be fixed but aren't fatal to the fetch execution
	WARNING
	// ERROR severity are diagnostics that were fatal in the fetch execution and should be fixed.
	ERROR
	// PANIC severity are diagnostics that are returned from a panic in the underlying code.
	PANIC
)

func (Severity) String added in v0.9.0

func (s Severity) String() string

type SquashedDiag

type SquashedDiag struct {
	Diagnostic
	// contains filtered or unexported fields
}

func (SquashedDiag) Count

func (s SquashedDiag) Count() uint64

Count returns the number of diagnostics inside the squashed diagnostic

func (SquashedDiag) Description

func (s SquashedDiag) Description() Description

func (SquashedDiag) Redacted added in v0.7.6

func (s SquashedDiag) Redacted() Diagnostic

Redacted returns the redacted version of the first diagnostic, if there is any

func (SquashedDiag) Unsquash added in v0.9.0

func (s SquashedDiag) Unsquash() Diagnostic

Unsquash returns the first diagnostic of the squashed set

type Type added in v0.9.0

type Type int

nolint:revive

const (
	UNKNOWN Type = iota
	RESOLVING
	ACCESS
	THROTTLE
	DATABASE
	SCHEMA
	INTERNAL
	USER
)

func (Type) String added in v0.9.0

func (d Type) String() string

type Unsquashable added in v0.9.0

type Unsquashable interface {
	Unsquash() Diagnostic
}

Jump to

Keyboard shortcuts

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