Documentation
¶
Index ¶
- Constants
- func NewError(skip int, flag error, msg string, args ...any) error
- func RegistryEntries[K comparable, V any](registry *Registry[K, V]) map[K]V
- func RegistryGet[K comparable, V any](registry *Registry[K, V], name K) (V, bool)
- func RegistrySet[K comparable, V any](registry *Registry[K, V], name K, value V) 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 ¶
func RegistryEntries[K comparable, V any](registry *Registry[K, V]) map[K]V
RegistryEntries returns a copy of the data in the registry.
func RegistryGet ¶
func RegistryGet[K comparable, V any](registry *Registry[K, V], name K) (V, bool)
RegistryGet returns the value referenced by name and a bool indicating if this value exists in the Registry.
func RegistrySet ¶
func RegistrySet[K comparable, V any](registry *Registry[K, V], name K, value V) error
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.
type Registry ¶
type Registry[K comparable, V any] struct { // contains filtered or unexported fields }
Registry holds an inner map[K]V with a mutex to protect accesses.
func NewRegistry ¶
func NewRegistry[K comparable, V any]() *Registry[K, V]
NewRegistry returns a Registry[K, V] pointer.