Documentation ¶
Overview ¶
package errpos provides position/syntax and context path based errors, compatible with linters and humans.
Index ¶
- func AddContext(err error, ctx ...string) error
- func AddFilename(err error, filename string) error
- func AddPosition(err error, pos Position) error
- func AddSource(err error, fileData string) error
- func AddSourceFile(err error, filename string, fileData string) error
- type Context
- type Err
- type Errors
- type ErrorsWithSource
- type HasPosition
- type Point
- type Position
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddContext ¶
WithContext adds context elements to an error. If err is nil, nil is returned If the errors.As matches `*Error` (not an interface), the input is added to the *start* of the existing context. Otherwise a new Error is returned.
func AddFilename ¶
func AddPosition ¶
AddPosition adds a source position to an error. If the error is nil, returns nil. If the error already has a position (implements Position), it is returned unmodified, as the existing value is likely more specific and useful.
Types ¶
type Context ¶
type Context []string
Context is the location of an error within a schema or other 'walkable' structure. The elements are arbitrary and defined by the producer.
type Err ¶
Error wraps it all together. Short names are annoying but - duck typing.
func (*Err) ErrorPosition ¶
type Errors ¶
type Errors []*Err
Errors allows a list of errors to be treated as a single error passing through the tree, but split out at the end, e.g. multiple syntax errors in a file.
type ErrorsWithSource ¶
type ErrorsWithSource struct { Errors Errors // contains filtered or unexported fields }
func AsErrorsWithSource ¶
func AsErrorsWithSource(err error) (*ErrorsWithSource, bool)
func MustAddSource ¶
func MustAddSource(err error, fileSource string) (*ErrorsWithSource, error)
func (ErrorsWithSource) Error ¶
func (e ErrorsWithSource) Error() string
func (ErrorsWithSource) HumanString ¶
func (e ErrorsWithSource) HumanString(contextLines int) string