Documentation
¶
Overview ¶
Package issue provides a common set of tools for describing problems encountered during processing.
Index ¶
- type Definition
- type Issue
- func (i *Issue) AppendRelated(file *source.File, loc source.Location, msg string, args ...any) *Issue
- func (i *Issue) Definition() *Definition
- func (i *Issue) Detail() string
- func (i *Issue) File() *source.File
- func (i *Issue) Location() source.Location
- func (i *Issue) Related() iter.Seq2[int, Related]
- func (i *Issue) String() string
- func (i *Issue) WithDetail(msg string, args ...any) *Issue
- type Log
- func (l *Log) All() iter.Seq2[int, *Issue]
- func (l *Log) Append(issue *Issue)
- func (l *Log) Errors() iter.Seq[*Issue]
- func (l *Log) First() *Issue
- func (l *Log) HasError() bool
- func (l *Log) HasInfo() bool
- func (l *Log) HasInternal() bool
- func (l *Log) HasWarning() bool
- func (l *Log) Infos() iter.Seq[*Issue]
- func (l *Log) Last() *Issue
- func (l *Log) Len() int
- func (l *Log) String() string
- func (l *Log) Warnings() iter.Seq[*Issue]
- type Related
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
Definition is a definition of a particular type of issue.
func NewError ¶
func NewError(id, description string) *Definition
NewError returns a new Definition for an Error issue.
func NewInfo ¶
func NewInfo(id, description string) *Definition
NewInfo returns a new Definition for an Info issue.
func NewInternal ¶
func NewInternal(id, description string) *Definition
NewInternal returns a new Definition for an Internal issue.
func NewWarning ¶
func NewWarning(id, description string) *Definition
NewWarning returns a new Definition for a Warning issue.
func (Definition) Description ¶
func (d Definition) Description() string
Description returns the standard human-readable description of the issue.
func (Definition) ID ¶
func (d Definition) ID() string
ID returns the unqiue identifier of this type of issue.
func (Definition) Severity ¶
func (d Definition) Severity() Severity
Severity returns the severity of the issue.
func (Definition) String ¶
func (d Definition) String() string
type Issue ¶
type Issue struct {
// contains filtered or unexported fields
}
Issue describes an issue found while processing input.
Issues never represent internal errors encountered in processing, those are conveyed via normal [error] returns.
func (*Issue) AppendRelated ¶
func (i *Issue) AppendRelated(file *source.File, loc source.Location, msg string, args ...any) *Issue
AppendRelated adds a related source location to this issue.
func (*Issue) Definition ¶
func (i *Issue) Definition() *Definition
Definition returns the metadata that defines what kind of issue this is.
func (*Issue) Detail ¶
Detail returns supplemental information that is required to clarify the issue if any.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is an ordered record of issues collected during processing.
func (*Log) HasInternal ¶
HasInternal returns true if the log has at least one Internal issue.
func (*Log) HasWarning ¶
HasWarning returns true if the log has at least one Warning issue.
type Related ¶
type Related struct {
// contains filtered or unexported fields
}
Related is a separate piece of source code that relates to some issue.
func (Related) Detail ¶
Detail returns supplemental information that is required to clarify how this location relates to the overall issue.
type Severity ¶
type Severity uint8
Severity describes how serious an issue detected by a processing step is.
const ( // Internal indicates an issue due to a fault in the system rather than user // input. The user is not expected to fix these issue, rather report them to // the system owner. // // Internal issues almost always interrupt processing. Internal Severity = iota // Error indicates an issue that the user must address. This likely indicates // that the input is invalid in some fundamental way (e.g. bad syntax). // // Error issues from one processing phase usually prevent progression onto the // next phase. Error // Warning indicates an issue that the user should address. While technically // valid, the input may not function as the user intended (e.g. unused // variables). // // Warning issues should never prevent further processing. Warning // Info indicates an issue that the user may address. This may be suggestions // to improve style, efficiency, etc. // // Info issues should never prevent further processing. Info )