Documentation
¶
Index ¶
- Constants
- func NewError(skip int, flag error, msg string, args ...any) error
- func RegistryEntries[T any](registry *Registry[T]) map[string]T
- func RegistryGet[T any](registry *Registry[T], name string) (T, bool)
- func RegistrySet[T any](registry *Registry[T], name string, value T) error
- func WrapError(cause error, skip int, flag error, msg string, args ...any) error
- type Bitset
- type HexBinary
- type RaisedErr
- type Registry
Constants ¶
const (
Error = errorFlag("utils: error")
)
Variables ¶
This section is empty.
Functions ¶
func NewError ¶
NewError returns a RaisedErr{} that contains file & line of where it was called.
skip allows controlling Caller frame resolution, if you are calling NewError directly set skip to 0, if you are calling NewError from an intermediary newError function set skip to 1...
func RegistryEntries ¶
RegistryEntries returns a copy of the data in the registry.
func RegistryGet ¶
RegistryGet returns the value referenced by name and a bool indicating if this value exists in the Registry.
func RegistrySet ¶
RegistrySet adds a new entry to the Registry. It errors if name is already in use.
func WrapError ¶
WrapError returns a RaisedErr{} that contains file & line of where it was called. If cause is nil, WrapError returns nil.
skip allows controlling Caller frame resolution, if you are calling NewError directly set skip to 0, if you are calling NewError from an intermediary newError function set skip to 1...
Types ¶
type Bitset ¶
type Bitset []byte
Bitset provides a bit array built on top of a byte slice. Each byte in the underlying slice encodes 8 bits.
func (Bitset) ClearBit ¶
ClearBit set the bit indexed by pos to 0. It errors if pos is not a valid index in the Bitset.
type HexBinary ¶
type HexBinary []byte
func (HexBinary) MarshalText ¶
func (*HexBinary) UnmarshalText ¶
type RaisedErr ¶
type RaisedErr struct {
// Flag allows grouping related errors.
Flag error
// Cause is the error that caused the RaisedErr{}.
Cause error
// Msg describes what happened.
Msg string
// Filename is the source file that contains the code that emitted the error.
Filename string
// Line is the location in the source file of the code that emitted the error.
Line int
}
RaisedErr is an error type that tracks error occurence location. All errors returned by KerPass code base functions are RaisedError instances.
Each package may define a private flag error type and a set of **constants** errors having such types. Those flags can be assigned to returned RaisedError to simplify error checking using golang errors.Is.