errors

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrInvalidValues

type ErrInvalidValues[T comparable] struct {
	// Values is the list of invalid values.
	Values []T
}

ErrInvalidValues represents an error when a value is in a list of invalid values.

func NewErrInvalidValues

func NewErrInvalidValues[T comparable](values []T) *ErrInvalidValues[T]

NewErrInvalidValues creates a new ErrInvalidValues error.

Parameters:

  • values: The list of invalid values.

Returns:

  • *ErrInvalidValues: A pointer to the newly created ErrInvalidValues.

func NewErrUnexpectedValue

func NewErrUnexpectedValue[T comparable](value T) *ErrInvalidValues[T]

NewErrUnexpectedValue is a function that creates a new ErrInvalidValues error.

Parameters:

  • value: The value that was unexpected.

Returns:

  • *ErrInvalidValues: A pointer to the newly created ErrInvalidValues.

func (*ErrInvalidValues[T]) Error

func (e *ErrInvalidValues[T]) Error() string

Error implements the error interface.

Message: "value must not be <value 0>, <value 1>, <value 2>, ..., or <value n>"

If no values are provided, the message is "value is invalid".

type ErrUnexpected

type ErrUnexpected struct {
	// Expected is the list of expected values.
	Expected []string

	// Actual is the actual value encountered.
	Actual string
}

ErrUnexpected represents an error that occurs when an unexpected value is encountered.

func NewErrUnexpected

func NewErrUnexpected(got string, expected ...string) *ErrUnexpected

NewErrUnexpected creates a new ErrUnexpected error.

Parameters:

  • got: The actual value encountered.
  • expected: The list of expected values.

Returns:

  • *ErrUnexpected: A pointer to the newly created ErrUnexpected.

func (*ErrUnexpected) Error

func (e *ErrUnexpected) Error() string

Error implements the error interface.

Message: "expected <value 0>, <value 1>, <value 2>, ..., or <value n>, got <actual> instead"

Jump to

Keyboard shortcuts

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