errors

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(err error, code ErrorCode) bool

Is checks if an error is a specific GroveError code

Types

type ErrorCode

type ErrorCode string

ErrorCode represents a specific error condition

const (
	// Configuration errors
	ErrCodeConfigNotFound   ErrorCode = "CONFIG_NOT_FOUND"
	ErrCodeConfigInvalid    ErrorCode = "CONFIG_INVALID"
	ErrCodeConfigValidation ErrorCode = "CONFIG_VALIDATION"

	// Container runtime errors
	ErrCodeContainerNotRunning ErrorCode = "CONTAINER_NOT_RUNNING"
	ErrCodeContainerTimeout    ErrorCode = "CONTAINER_TIMEOUT"
	ErrCodeComposeNotFound     ErrorCode = "COMPOSE_NOT_FOUND"
	ErrCodeServiceNotFound     ErrorCode = "SERVICE_NOT_FOUND"
	ErrCodeServiceNotRunning   ErrorCode = "SERVICE_NOT_RUNNING"

	// Network errors
	ErrCodePortConflict  ErrorCode = "PORT_CONFLICT"
	ErrCodeNetworkCreate ErrorCode = "NETWORK_CREATE"

	// Command execution errors
	ErrCodeCommandTimeout  ErrorCode = "COMMAND_TIMEOUT"
	ErrCodeCommandNotFound ErrorCode = "COMMAND_NOT_FOUND"
	ErrCodeCommandFailed   ErrorCode = "COMMAND_FAILED"

	// Git errors
	ErrCodeGitNotInstalled ErrorCode = "GIT_NOT_INSTALLED"
	ErrCodeGitCloneFailed  ErrorCode = "GIT_CLONE_FAILED"
	ErrCodeGitDirty        ErrorCode = "GIT_DIRTY"

	// General errors
	ErrCodeInternal         ErrorCode = "INTERNAL_ERROR"
	ErrCodeInvalidInput     ErrorCode = "INVALID_INPUT"
	ErrCodePermissionDenied ErrorCode = "PERMISSION_DENIED"
)

func GetCode

func GetCode(err error) ErrorCode

GetCode extracts the error code from an error

type GroveError

type GroveError struct {
	Code    ErrorCode              `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
	Cause   error                  `json:"-"`
}

GroveError represents a structured error with context

func CommandFailed

func CommandFailed(cmd string, err error) *GroveError

CommandFailed creates a command execution failure error

func ConfigInvalid

func ConfigInvalid(reason string) *GroveError

ConfigInvalid creates an invalid configuration error

func ConfigNotFound

func ConfigNotFound(path string) *GroveError

ConfigNotFound creates a configuration not found error

func ContainerTimeout

func ContainerTimeout(service string, timeout string) *GroveError

ContainerTimeout creates a container timeout error

func New

func New(code ErrorCode, message string) *GroveError

New creates a new GroveError

func PortConflict

func PortConflict(port int, service string) *GroveError

PortConflict creates a port conflict error

func ServiceNotFound

func ServiceNotFound(service string) *GroveError

ServiceNotFound creates a service not found error

func Wrap

func Wrap(err error, code ErrorCode, message string) *GroveError

Wrap wraps an existing error with a GroveError

func (*GroveError) Error

func (e *GroveError) Error() string

Error implements the error interface

func (*GroveError) ToJSON

func (e *GroveError) ToJSON() string

ToJSON converts the error to JSON

func (*GroveError) Unwrap

func (e *GroveError) Unwrap() error

Unwrap implements the errors.Unwrap interface

func (*GroveError) WithDetail

func (e *GroveError) WithDetail(key string, value interface{}) *GroveError

WithDetail adds a detail to the error

Jump to

Keyboard shortcuts

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