Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check checks a set of invariants and returns an error if any of them fail. Each invariant is passed as a pair: the name of the invariant as a string and a value that may be a boolean or error or function that return either of these types. If any value is false or a non-nil error across the pairs, then an error is returned with all the unmet invariants. Since this function checks multiple invariants, a group name is used to relate these checks together.
Types ¶
type CheckError ¶
type CheckError struct {
// ID is the name of the invariant that was not met.
ID string
// Group is a label that relates this error to others.
Group string
// The location in code where the invariant was checked.
Caller string
// Cause is the underlying error that caused the invariant check to fail.
Cause error
}
CheckError represents an invariant mismatch. If the invariant failed because of a non-nil error then Cause will be set.
func (*CheckError) Error ¶
func (ae *CheckError) Error() string
Error returns a string representation of the invariant error.
func (*CheckError) Unwrap ¶
func (ae *CheckError) Unwrap() error
Unwrap returns the underlying error that caused the invariant check to fail.
type InvariantError ¶
type InvariantError struct {
Failures []*CheckError
}
InvariantError captures a group of invariant check failures.
func (*InvariantError) Error ¶
func (e *InvariantError) Error() string