geomerr

package
v0.0.0-...-9c88ebf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxSliceErrs = 10

MaxSliceErrs limits the number of errors that will be reported by SliceErrs.Error

Functions

func NewLenMismatch

func NewLenMismatch(expected, actual int) (min, max int, err error)

NewLenMismatch will return a nil error if expected and actual are equal and an instance of LenMismatch if they are different. The min and max will be set to the smaller and larger of the values passed in respectivly.

func NewNotEqual

func NewNotEqual(areEqual bool, expected, actual interface{}) error

NewNotEqual will return nil if areEqual is true and will create an instance of ErrNotEqual if it is false.

func NewSliceErrs

func NewSliceErrs(lnExpected, lnActual int, fn func(int) error) error

NewSliceErrs creates an instance of SliceErrs by calling the provided func for every value up to Min(lnExpected, lnActual). If lnExpected and lnActual are not equal and instance of LenMismatch will be added to the start of the SliceErrs with an index of -1. If lnActual == -1 the length check is ignored.

func NewTypeMismatch

func NewTypeMismatch(expected, actual interface{}) error

NewTypeMismatch will return nil if the given types are the same and returns ErrTypeMismatch if they do not.

Types

type ErrLenMismatch

type ErrLenMismatch struct {
	Expected, Actual int
}

ErrLenMismatch represents a mis-matched length.

func LenMismatch

func LenMismatch(expected, actual int) ErrLenMismatch

LenMismatch returns an ErrLenMismatch.

func (ErrLenMismatch) Error

func (e ErrLenMismatch) Error() string

Error fulfills the error interface.

type ErrNotEqual

type ErrNotEqual struct {
	Expected, Actual interface{}
}

ErrNotEqual is used to indicate two values that were expected to be equal. were not.

func NotEqual

func NotEqual(expected, actual interface{}) ErrNotEqual

NotEqual creates an instance of ErrNotEqual.

func (ErrNotEqual) Error

func (e ErrNotEqual) Error() string

Error fulfills the error interface.

type ErrTypeMismatch

type ErrTypeMismatch struct {
	Expected, Actual reflect.Type
}

ErrTypeMismatch indicates that two types that were expected to be equal were not.

func TypeMismatch

func TypeMismatch(expected, actual interface{}) ErrTypeMismatch

TypeMismatch creates an instance of ErrTypeMismatch.

func (ErrTypeMismatch) Error

func (e ErrTypeMismatch) Error() string

Error fulfills the error interface.

type SliceErrRecord

type SliceErrRecord struct {
	// Index of the reference slice
	Index int
	Err   error
}

SliceErrRecord represents an error comparing two slices. An index less than 0 is treated as an error on the underlying comparison and will be printed without the index. For instance, if the lengths of the slices are not the same.

type SliceErrs

type SliceErrs []SliceErrRecord

SliceErrs collects SliceErrRecord and treats them as a single error.

func (SliceErrs) Append

func (e SliceErrs) Append(idx int, err error) SliceErrs

Append a SliceErrRecord to SliceErrs. If err is nil it will not be appended.

func (SliceErrs) AppendF

func (e SliceErrs) AppendF(idx int, format string, args ...interface{}) SliceErrs

AppendF uses fmt.Errorf to append a SliceErrRecord to SliceErrs .

func (SliceErrs) Error

func (e SliceErrs) Error() string

Error fulfills the error interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL