corgierr

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	File *file.File
	// ContextStart and ContextEnd are the lines of input relevant to the
	// annotation, which are printed when the Pretty is called.
	//
	// Usually that is the line on which the error occurred, however, the
	// context may be larger if there is more relevant information to show.
	// For example a mixin argument error may choose to include the point when
	// the mixin was called.
	//
	// ContextStart is inclusive and ContextEnd is exclusive.
	ContextStart, ContextEnd int
	// Line is the line of the annotation.
	// It must lie between ContextStart and ContextEnd.
	Line int
	// Start and End specify the col range to be highlighted.
	//
	// Note that Start and End may exceed the actual line length.
	//
	// This is, for example, useful to highlight a missing token at the end of
	// a line.
	//
	// Start is inclusive and End is exclusive.
	Start, End int
	Annotation string

	// Lines are the lines that are annotated, starting with the line with the
	// number ContextStart.
	Lines []string
	// contains filtered or unexported fields
}

type Error

type Error struct {
	Message string

	ErrorAnnotation Annotation
	HintAnnotations []Annotation

	Example     string
	ShouldBe    string
	Suggestions []Suggestion

	// Cause is the cause of the error, if it has one
	Cause error
}

func (*Error) Error

func (err *Error) Error() string

func (*Error) Pretty

func (err *Error) Pretty(o PrettyOptions) string

func (*Error) Unwrap

func (err *Error) Unwrap() error

type List

type List []*Error //nolint:errname

List represents a collection of Error objects.

func As

func As(err error) List

As returns a List if errors.As yields a List or an Error.

func (List) Error

func (l List) Error() string

Error calls Error.Error for each item in the list, separating them by newlines.

func (List) Len

func (l List) Len() int

func (List) Less

func (l List) Less(i, j int) bool

func (List) Pretty

func (l List) Pretty(o PrettyOptions) string

Pretty calls Error.Pretty on each item in the list, separating each error by two newlines (effectively leaving a single blank line in-between errors).

func (List) Swap

func (l List) Swap(i, j int)

type PrettyOptions

type PrettyOptions struct {
	FileNamePrinter func(*file.File) string
	Colored         bool
}

type Suggestion

type Suggestion struct {
	Suggestion string
	Example    string
	ShouldBe   string
	Code       string
}

Jump to

Keyboard shortcuts

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