Documentation ¶
Overview ¶
Package errorglue contains non-essential error declarations
Index ¶
- func ChainString(err error, format CSFormat) (s string)
- func DumpChain(err error) (typeNames string)
- func DumpGo(err error) (typeNames string)
- func ErrorChainSlice(err error) (errs []error)
- func ErrorsWithStack(err error) (errs []error)
- func GetInnerMostStack(err error) (stack pruntime.StackSlice)
- func GetStackTrace(err error) (stack pruntime.StackSlice)
- func GetStacks(err error) (stacks []pruntime.StackSlice)
- func IsMinusFlag(s fmt.State) bool
- func IsPlusFlag(s fmt.State) bool
- func IsQuoteVerb(r rune) bool
- func IsStringVerb(r rune) bool
- func IsValueVerb(r rune) bool
- func NewErrorData(err error, key, value string) (e2 error)
- func NewErrorStack(err error, st pruntime.StackSlice) (e2 error)
- func NewRelatedError(err, err2 error) (e2 error)
- func NewWarning(err error) error
- func RecoverThread(label string, onError func(err error))
- type CSFormat
- type ChainStringer
- type ErrorCallStacker
- type ErrorChain
- type ErrorHasCode
- type ErrorHasData
- type ErrorStore
- type RelatedError
- type RichError
- type SendChannel
- type SendNb
- type WarningType
- type Wrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChainString ¶
ChainString() gets a string representation of a single error chain TODO 220319 finish comment
func DumpChain ¶
DumpChain retrieves a space-separated string of error implementation type-names found in the error chain of err. err can be nil
fmt.Println(Stack(errors.New("an error"))) *error116.errorStack *errors.errorString
func DumpGo ¶ added in v0.3.0
DumpGo produces a newline-separated string of type-names and Go-syntax found in the error chain of err. err can be nil
func ErrorChainSlice ¶
ErrorChainSlice returns a slice of errors from a possible error chain. If err is nil, an empty slice is returned. If err does not have an error chain, a slice of only err is returned. Otherwise, the slice lists each error in the chain starting with err at index 0 ending with the oldest error of the chain
func ErrorsWithStack ¶
ErrorsWithStack gets all errors in the err error chain that has a stack trace. Oldest innermost stack trace is returned first. if not stack trace is present, the slice is empty
func GetInnerMostStack ¶
func GetInnerMostStack(err error) (stack pruntime.StackSlice)
GetInnerMostStack gets the oldest stack trace in the error chain
func GetStackTrace ¶
func GetStackTrace(err error) (stack pruntime.StackSlice)
GetStackTrace gets the last stack trace
func GetStacks ¶
func GetStacks(err error) (stacks []pruntime.StackSlice)
GetStacks gets a slice of all stack traces, oldest first
func IsMinusFlag ¶
IsMinusFlag determines if fmt.State has the '-' flag
func IsPlusFlag ¶
IsPlusFlag determines if fmt.State has the '+' flag
func IsQuoteVerb ¶
IsQuoteVerb determines if the rune corresponds to the %q quote verb
func IsStringVerb ¶
IsStringVerb determines if the rune corresponds to the %s string verb
func IsValueVerb ¶
IsValueVerb determines if the rune corresponds to the %v value verb
func NewErrorData ¶
func NewErrorStack ¶
func NewErrorStack(err error, st pruntime.StackSlice) (e2 error)
func NewRelatedError ¶
func NewWarning ¶
func RecoverThread ¶ added in v0.2.2
RecoverThread is a defer function for threads. On panic, the onError function is invoked with an error message that contains location information
Types ¶
type CSFormat ¶ added in v0.2.2
type CSFormat byte
CSFormat describes string conversion of an error chain
const ( // DefaultFormat is similar to printf %v, printf %s and error.Error(). // For an error with data, stack trace and associated errors, // DefaultFormat only prints the error message: // error-message DefaultFormat CSFormat = iota + 1 // ShortFormat has one-line location similar to printf %-v. // ShortFormat does not print stack traces, data and associated errors. // ShortFormat does print a one-liner of the error message and a brief code location: // error-message at error116.(*csTypeName).FuncName-chainstring_test.go:26 ShortFormat // LongFormat is similar to printf %+v. // ShortFormat does not print stack traces, data and associated errors. // error-message // github.com/haraldrudell/parl/error116.(*csTypeName).FuncName // /opt/sw/privates/parl/error116/chainstring_test.go:26 // runtime.goexit // /opt/homebrew/Cellar/go/1.17.8/libexec/src/runtime/asm_arm64.s:1133 LongFormat // ShortSuffix one-line without message ShortSuffix // LongSuffix full stack trace without message LongSuffix )
func PrintfFormat ¶
PrintfFormat gets the ErrorFormat to use when executing the Printf value verb 'v'
type ChainStringer ¶
type ChainStringer interface { // ChainString is used by ChainStringer() to obtain comprehensive // string representations of errors. // The argument isIgnore() is used to avoid printing cyclic error values. // If a ChainStringer pointer receiver gets a nil value, the empty string is returned. // ChainString() obtains a string representation of the errors in its chain. // Rich errors implement either ChainStringer or fmt.Formatter ChainString(format CSFormat) string }
ChainStringer obntain s a comprehensive string representation of an error chain. formats used are DefaultFormat ShortFormat LongFormat ShortSuffix LongSuffix
type ErrorCallStacker ¶
type ErrorCallStacker interface {
StackTrace() pruntime.StackSlice
}
ErrorCallStacker enrichens an error with a stack trace of code locations
type ErrorChain ¶
type ErrorChain struct {
// contains filtered or unexported fields
}
ErrorChain implements a chain of errors. Error chains do exist in the Go standard library but types and interfaces are not public. ErrorChain is used as an embedded type. ErrorChain’s publics are Error() and Unwrap()
ErrorChainSlice returns all errors of an error chain, or the chain can be traversed iteratively using errors.Unwrap()
func (*ErrorChain) Unwrap ¶
func (ec *ErrorChain) Unwrap() error
Unwrap is a method required to make ErrorChain an error chain ErrorChain.Unwrap() is used by errors.Unwrap() and ErrorChainSlice
type ErrorHasCode ¶
type ErrorHasCode interface { // Check if this error claims a particular Linux errno, an int IsErrno(errno int) (hasErrno bool) // ErrorCode determines if this error claims code, a string ErrorCode(code string) (hasCode bool) // ErrorCodes returns codes that this error claims, some are numeric strings mapping to an errno ErrorCodes(codes []string) (has []string) }
ErrorHasCode allows an error to classify itself
type ErrorHasData ¶
type ErrorHasData interface {
KeyValue() (key, value string)
}
ErrorHasData enrichens an error with key and value strings
type ErrorStore ¶ added in v0.2.2
type ErrorStore interface { AddError(err error) (e error) GetError() (e error) InvokeIfError(fn func(err error)) Error() (message string) }
ErrorStore is a thread-safe store for any number of errors
type RelatedError ¶
type RelatedError interface {
AssociatedError() (error error)
}
RelatedError enrichens an error with an enclosed additional error value
type RichError ¶
type RichError struct {
ErrorChain
}
RichError is an error chain that behaves like fmt.Formatter. this allows for custom print-outs using %+v and %-v RichError has publics Error() Unwrap() Format()
type SendChannel ¶ added in v0.2.2
type SendChannel struct {
// contains filtered or unexported fields
}
ParlError is a thread-safe error container
func NewSendChannel ¶ added in v0.2.2
func NewSendChannel(errCh chan<- error) (sc *SendChannel)
func (*SendChannel) Send ¶ added in v0.2.2
func (sc *SendChannel) Send(err error)
Send sends an error on the error channel. Thread-safe
func (*SendChannel) Shutdown ¶ added in v0.2.2
func (sc *SendChannel) Shutdown()
Shutdown closes the channel exactly once. Thread-safe
type SendNb ¶ added in v0.2.2
type SendNb struct { SendChannel // contains filtered or unexported fields }
SendNb implements non-blocking send using a thread and buffer up to size of int
type WarningType ¶
type WarningType struct {
ErrorChain
}
warningType is an error with lesser impact
func (*WarningType) Error ¶
func (w *WarningType) Error() (s string)
Error prepends “Warning: ” to the error message