Documentation
¶
Index ¶
- func AsError(errorText string) func(loc *SrcLocation)
- func AsHelp(helpText string) func(loc *SrcLocation)
- func AsWarning(warningText string) func(loc *SrcLocation)
- type LocationKind
- type LocationOption
- type LocationType
- type RangeOption
- type SrcLocation
- type Template
- func (t Template) AtGoNode(node goAst.Node, options ...LocationOption) Template
- func (t Template) AtGoPos(start, end goToken.Pos, options ...LocationOption) Template
- func (t Template) AtGoPosition(start, end goToken.Position, options ...LocationOption) Template
- func (t Template) InFile(filepath string, options ...LocationOption) Template
- func (t Template) WithDetails(details string) Template
- func (t Template) Wrapping(err error) Template
- type TemplateOption
- type TemplateRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsError ¶
func AsError(errorText string) func(loc *SrcLocation)
AsError allows you to set a SrcLocation's error text
Pass this option in when you give the error Template a src location
func AsHelp ¶
func AsHelp(helpText string) func(loc *SrcLocation)
AsHelp allows you to set a SrcLocation's text and mark it as a helpful hint
Pass this option in when you give the error Template a src location
func AsWarning ¶
func AsWarning(warningText string) func(loc *SrcLocation)
AsWarning allows you to set a SrcLocation's text and mark it as a warning
Pass this option in when you give the error Template a src location
Types ¶
type LocationKind ¶
type LocationKind uint8
LocationKind tells us what language and position markers we're using to identify the source
const ( LocFile LocationKind = iota LocGoNode LocGoPos LocGoPositions )
type LocationOption ¶
type LocationOption func(*SrcLocation)
type LocationType ¶
type LocationType uint8
LocationType represents if the locaton is the source of the error, a warning or a helpful hint
const ( LocError LocationType = iota LocWarning LocHelp )
type RangeOption ¶
type RangeOption func(*rangeConfig)
func WithRangeSize ¶
func WithRangeSize(size int) RangeOption
WithRangeSize sets the size of the range. The default is 100.
type SrcLocation ¶
type SrcLocation struct {
Kind LocationKind
LocType LocationType
Text string
Filepath string
GoNode goAst.Node
GoStartPos goToken.Pos
GoEndPos goToken.Pos
GoStartPosition goToken.Position
GoEndPosition goToken.Position
}
SrcLocation tells us where in the code base caused the error, warning or is a hint to the end user.
type Template ¶
type Template struct {
Code int
Title string
Summary string
Detail string
Cause error
Locations []SrcLocation
AlwaysIncludeStack bool
}
Template represents a template for a new error.
It itself is not an error, but can be used to initialize a new [errorinsrc.ErrInSrc].
func AtOptionalNode ¶
AtOptionalNode returns an error at the given node if it is present. Otherwise, it returns the error unchanged.