utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindSuggestions

func FindSuggestions(input string, options []string, maxSuggestions int) []string

FindSuggestions returns similar strings using simple edit distance (basic implementation - can be improved with Levenshtein distance)

func IsConfigError

func IsConfigError(err error) bool

IsConfigError checks if the error is configuration-related

func IsDockerError

func IsDockerError(err error) bool

IsDockerError checks if error is Docker-related

func IsKind

func IsKind(err error, kind ErrorKind) bool

IsKind checks if an error is of a specific kind

func IsNetworkError

func IsNetworkError(err error) bool

IsNetworkError checks if the error is network-related

func Wrap

func Wrap(err error, op, message string) error

Wrap adds context to an existing error

func WrapWithHint

func WrapWithHint(err error, op, message, hint string) error

WrapWithHint adds context and a hint to an existing error

Types

type ErrorKind

type ErrorKind string

ErrorKind represents the category of error

const (
	ErrorConfig     ErrorKind = "config"     // Configuration errors
	ErrorDocker     ErrorKind = "docker"     // Docker-related errors
	ErrorNetwork    ErrorKind = "network"    // Network/port errors
	ErrorGit        ErrorKind = "git"        // Git operations
	ErrorService    ErrorKind = "service"    // Service management
	ErrorFile       ErrorKind = "file"       // File system errors
	ErrorValidation ErrorKind = "validation" // Validation failures
	ErrorInternal   ErrorKind = "internal"   // Unexpected internal errors
)

type OrkError

type OrkError struct {
	// Op is the operation that failed (e.g., "docker.start", "config.load")
	Op string

	// Kind categorizes the error
	Kind ErrorKind

	// Err is the underlying error
	Err error

	// Message is a user-friendly description of what went wrong
	Message string

	// Hint provides a suggestion for how to fix the error
	Hint string

	// Details provides additional context (optional)
	Details []string

	// Suggestions provide "did you mean?" style suggestions (optional)
	Suggestions []string
}

OrkError is a rich error type that provides context, hints, and suggestions

func ConfigError

func ConfigError(op, message, hint string, err error) *OrkError

ConfigError creates a configuration-related error

func DockerError

func DockerError(op, message, hint string, err error) *OrkError

DockerError creates a Docker-related error

func ErrCircularDependency

func ErrCircularDependency(cycle []string) *OrkError

ErrCircularDependency creates an error for circular service dependencies

func ErrConfigNotFound

func ErrConfigNotFound(path string) *OrkError

ErrConfigNotFound creates an error for when ork.yml is missing

func ErrDockerNotRunning

func ErrDockerNotRunning(err error) *OrkError

ErrDockerNotRunning creates an error for when the Docker daemon is not running

func ErrImageNotFound

func ErrImageNotFound(imageName string) *OrkError

ErrImageNotFound creates an error for missing Docker images

func ErrInvalidConfig

func ErrInvalidConfig(field, reason string) *OrkError

ErrInvalidConfig creates an error for invalid configuration

func ErrPortInUse

func ErrPortInUse(port, service, conflictingProcess string) *OrkError

ErrPortInUse creates an error for port conflicts

func ErrServiceFailed

func ErrServiceFailed(serviceName, reason string) *OrkError

ErrServiceFailed creates an error for when a service fails to start

func ErrServiceNotFound

func ErrServiceNotFound(serviceName string, availableServices []string) *OrkError

ErrServiceNotFound creates an error for unknown service names

func FileError

func FileError(op, message, hint string, err error) *OrkError

FileError creates a file system error

func NetworkError

func NetworkError(op, message, hint string, err error) *OrkError

NetworkError creates a network/port-related error

func ServiceError

func ServiceError(op, message, hint string, err error) *OrkError

ServiceError creates a service management error

func ValidationError

func ValidationError(op, message string, suggestions []string) *OrkError

ValidationError creates a validation error with suggestions

func (*OrkError) Error

func (e *OrkError) Error() string

Error implements the error interface

func (*OrkError) Unwrap

func (e *OrkError) Unwrap() error

Unwrap returns the underlying error (for errors.Is and errors.As)

Jump to

Keyboard shortcuts

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