Documentation
¶
Index ¶
- func Stringer(v interface{}) fmt.Stringer
- type Location
- type Option
- type Position
- type Severity
- type Stack
- type StackTrace
- func (st *StackTrace) Append(e *StackTrace) *StackTrace
- func (st *StackTrace) Error() string
- func (st *StackTrace) GetLocWithPos() string
- func (st *StackTrace) GetLocWithPosPtr() *string
- func (st *StackTrace) GetTraces(opts ...TracesOpt) []Trace
- func (st *StackTrace) Header() string
- func (st *StackTrace) Is(err error) bool
- func (st *StackTrace) MessageWithInfo() string
- func (st *StackTrace) OrigString() string
- func (st *StackTrace) OrigStringW() string
- func (st *StackTrace) SetErr(err error) *StackTrace
- func (st *StackTrace) SetLocation(location string) *StackTrace
- func (st *StackTrace) SetMessage(message string, a ...any) *StackTrace
- func (st *StackTrace) SetPosition(pos *Position) *StackTrace
- func (st *StackTrace) SetSeverity(severity Severity) *StackTrace
- func (st *StackTrace) SetType(t Type) *StackTrace
- func (st *StackTrace) String() string
- func (st *StackTrace) Wrap(w *StackTrace) *StackTrace
- type StructInfo
- func (s *StructInfo) Add(key string, value fmt.Stringer) *StructInfo
- func (s *StructInfo) Get(key string) fmt.Stringer
- func (s *StructInfo) Has(key string) bool
- func (s *StructInfo) Keys() []string
- func (s *StructInfo) Remove(key string) *StructInfo
- func (s *StructInfo) SortedKeys() []string
- func (s *StructInfo) String() string
- func (s *StructInfo) StringBy(key string) string
- func (s *StructInfo) Update(u *StructInfo) *StructInfo
- type Trace
- type TracesOpt
- type TracesOptions
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option interface {
Apply(*StackTrace)
}
Option is an option for the StackTrace creation.
func WithLocation ¶
WithLocation sets the location of the error.
func WithPosition ¶
func WithSeverity ¶
type Position ¶
Position contains the line and column where the error occurred.
func NewPosition ¶
NewPosition creates a new position with the given line and column.
type StackTrace ¶
type StackTrace struct { // Severity is the severity of the error. Severity *Severity // Type is the type of the error. Type *Type // Location is the location file path of the error. Location *Location // Position is the position of the error in the file. Position *Position // Wrapped is the error that wrapped by this error. Wrapped *StackTrace // Err is the underlying error. It is not used for the error message. Err error // Message is the error message. Message string // Info is the additional information about the error. Info StructInfo // List is the list of stack traces. List []*StackTrace // contains filtered or unexported fields }
StackTrace contains information about a parser error.
func NewWrapped ¶
func NewWrapped(message string, err error, opts ...Option) *StackTrace
NewWrapped creates a new StackTrace from the given go error.
func Unwrap ¶
func Unwrap(err error) (*StackTrace, bool)
Unwrap checks if the given error is a StackTrace and returns it. It returns false if the error is not a StackTrace. if err is a StackTrace, it returns the wrapped StackTrace and true. if err is not a StackTrace, it is unwrapped and wrapped with a new StackTrace if it has a wrapped StackTrace.
func Wrap ¶
func Wrap(err error, opts ...Option) *StackTrace
Wrap wraps the given error with the StackTrace if it is not a StackTrace. It returns the wrapped StackTrace.
func (*StackTrace) Append ¶
func (st *StackTrace) Append(e *StackTrace) *StackTrace
Append adds the given StackTrace to the list of StackTraces and returns it
func (*StackTrace) Error ¶
func (st *StackTrace) Error() string
StackTrace implements the error interface. It returns the string representation of the StackTrace.
func (*StackTrace) GetLocWithPos ¶
func (st *StackTrace) GetLocWithPos() string
GetLocWithPos returns the location with position of the StackTrace.
func (*StackTrace) GetLocWithPosPtr ¶
func (st *StackTrace) GetLocWithPosPtr() *string
GetLocWithPosPtr returns the location with position of the StackTrace.
func (*StackTrace) GetTraces ¶
func (st *StackTrace) GetTraces(opts ...TracesOpt) []Trace
func (*StackTrace) Header ¶
func (st *StackTrace) Header() string
Header returns the header of the StackTrace.
func (*StackTrace) Is ¶
func (st *StackTrace) Is(err error) bool
Is checks if the given error is the same as the StackTrace.
func (*StackTrace) MessageWithInfo ¶
func (st *StackTrace) MessageWithInfo() string
func (*StackTrace) OrigString ¶
func (st *StackTrace) OrigString() string
OrigString returns the original error message without the wrapping messages.
func (*StackTrace) OrigStringW ¶
func (st *StackTrace) OrigStringW() string
OrigStringW returns the original error message with the wrapped OrigStringW
func (*StackTrace) SetErr ¶
func (st *StackTrace) SetErr(err error) *StackTrace
SetErr sets the underlying error of the StackTrace and returns it
func (*StackTrace) SetLocation ¶
func (st *StackTrace) SetLocation(location string) *StackTrace
SetLocation sets the location of the StackTrace and returns it
func (*StackTrace) SetMessage ¶
func (st *StackTrace) SetMessage(message string, a ...any) *StackTrace
SetMessage sets the message of the StackTrace and returns it
func (*StackTrace) SetPosition ¶
func (st *StackTrace) SetPosition(pos *Position) *StackTrace
SetPosition sets the position of the StackTrace and returns it
func (*StackTrace) SetSeverity ¶
func (st *StackTrace) SetSeverity(severity Severity) *StackTrace
SetSeverity sets the severity of the StackTrace and returns it
func (*StackTrace) SetType ¶
func (st *StackTrace) SetType(t Type) *StackTrace
SetType sets the type of the StackTrace and returns it, operation can be done only once.
func (*StackTrace) String ¶
func (st *StackTrace) String() string
String implements the fmt.Stringer interface. It returns the string representation of the StackTrace.
func (*StackTrace) Wrap ¶
func (st *StackTrace) Wrap(w *StackTrace) *StackTrace
Wrap wraps the given StackTrace and returns it
type StructInfo ¶
type StructInfo struct {
// contains filtered or unexported fields
}
StructInfo is a map of string keys to fmt.Stringer values. It is used to store additional information about an error. WARNING: Not thread-safe
func (*StructInfo) Add ¶
func (s *StructInfo) Add(key string, value fmt.Stringer) *StructInfo
Add adds a key-value pair to the struct info.
func (*StructInfo) Get ¶
func (s *StructInfo) Get(key string) fmt.Stringer
Get returns the value of the given key.
func (*StructInfo) Has ¶
func (s *StructInfo) Has(key string) bool
Has checks if the given key exists in the struct info.
func (*StructInfo) Keys ¶
func (s *StructInfo) Keys() []string
Keys returns the keys of the struct info.
func (*StructInfo) Remove ¶
func (s *StructInfo) Remove(key string) *StructInfo
Remove removes the given key from the struct info.
func (*StructInfo) SortedKeys ¶
func (s *StructInfo) SortedKeys() []string
SortedKeys returns the sorted keys of the struct info.
func (*StructInfo) String ¶
func (s *StructInfo) String() string
String implements the fmt.Stringer interface. It returns a string representation of the struct info.
func (*StructInfo) StringBy ¶
func (s *StructInfo) StringBy(key string) string
StringBy returns the string value of the given key.
func (*StructInfo) Update ¶
func (s *StructInfo) Update(u *StructInfo) *StructInfo
Update updates the struct info with the given struct info.
type TracesOpt ¶
type TracesOpt interface {
Apply(o *TracesOptions)
}
func WithEnsureDuplicates ¶
func WithEnsureDuplicates() TracesOpt
type TracesOptions ¶
type TracesOptions struct { // EnsureDuplicates ensures that duplicates are not printed EnsureDuplicates bool // contains filtered or unexported fields }
func NewTracesOptions ¶
func NewTracesOptions() *TracesOptions