errors

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package errors provides error related functions and types

Index

Constants

This section is empty.

Variables

View Source
var (
	// System Errors
	ErrSystemNotReady       = errors.New("system not ready")
	ErrElementNotFound      = errors.New("element not found")
	ErrNoNamedConfigSupport = errors.New("backend does not support named configs")
	ErrTLSCertificate       = errors.New("TLS certificate validation failed")

	// API Errors
	ErrAPIRequestFailed = errors.New("API request failed")
	ErrAPIUnauthorized  = errors.New("API authentication failed")
	ErrAPINotFound      = errors.New("API resource not found")
	ErrAPIConflict      = errors.New("API resource conflict")
	ErrAPIServerError   = errors.New("API server error")

	// Validation Errors
	ErrValidationFailed = errors.New("validation failed")
	ErrInvalidInput     = errors.New("invalid input")
	ErrMissingRequired  = errors.New("missing required field")

	// Authentication Errors
	ErrAuthFailed   = errors.New("authentication failed")
	ErrTokenExpired = errors.New("authentication token expired")
	ErrTokenInvalid = errors.New("authentication token invalid")

	// Network/Connection Errors
	ErrConnectionFailed = errors.New("connection failed")
	ErrTimeout          = errors.New("operation timeout")
)

Sentinel Errors

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if error indicates resource not found

func IsTLSCertificateError

func IsTLSCertificateError(err error) bool

IsTLSCertificateError checks if an error is a TLS/certificate validation error

func IsTemporary

func IsTemporary(err error) bool

IsTemporary checks if error is temporary and operation can be retried

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized checks if error indicates authentication failure

func Wrap

func Wrap(err error, operation string) error

Wrap creates a standardized wrapped error

func WrapTLSError

func WrapTLSError(err error) error

WrapTLSError wraps a TLS error with a clear sentinel value

func Wrapf

func Wrapf(err error, format string, args ...any) error

Wrapf creates a formatted wrapped error

Types

type APIError

type APIError struct {
	Operation  string `json:"operation"`
	StatusCode int    `json:"status_code"`
	Message    string `json:"message"`
	Cause      error  `json:"-"`
}

APIError represents a structured API error response

func NewAPIError

func NewAPIError(operation string, statusCode int, message string, cause error) *APIError

NewAPIError creates a structured API error

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type ValidationError

type ValidationError struct {
	Field  string `json:"field"`
	Value  any    `json:"value,omitempty"`
	Reason string `json:"reason"`
	Cause  error  `json:"-"`
}

ValidationError represents a structured validation error

func NewValidationError

func NewValidationError(field string, value any, reason string, cause error) *ValidationError

NewValidationError creates a structured validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Jump to

Keyboard shortcuts

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