Documentation
¶
Overview ¶
Package types defines validation error types used across the abyss project.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseHumanError ¶ added in v0.0.3
BaseHumanError is the most basic version of HumanError, and simply embeds a static human error message inside it.
func NewHumanError ¶ added in v0.0.3
func NewHumanError(err error, messages ...string) *BaseHumanError
NewHumanError wraps err with a human-readable message.
func (*BaseHumanError) Error ¶ added in v0.0.3
func (e *BaseHumanError) Error() string
Error returns the underlying error message.
func (*BaseHumanError) HumanError ¶ added in v0.0.3
func (e *BaseHumanError) HumanError() string
HumanError returns the human-readable message.
type HumanError ¶ added in v0.0.3
HumanError is an extension of the built-in error that also bundles a more human-readable variant of the message. I.e. where the normal error might say "failed to open file ...: $error message", HumanError would contain something more helpful like "failed while trying to read your configuration file. Make sure it exists and has correct permissions."
type ValidationError ¶
type ValidationError struct {
// The name of the type that failed validation. Usually the name of a struct.
Type string
// The name of the field that failed to validate.
Field string
// A human-readable explanation of why validation failed, like "should be non-zero"
Reason string
}
ValidationError is a custom error type that embeds information about a failed validation, such as the field that was invalid.
func NewValidationError ¶
func NewValidationError(from any, field string, reason string) *ValidationError
NewValidationError constructs a ValidationError describing the given field and reason for the failure on the provided value.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.