errors

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrorCode

func IsErrorCode(err error, code ErrorCode) bool

IsErrorCode 检查错误是否是指定的错误代码

Types

type AgentError

type AgentError struct {
	Code    ErrorCode
	Message string
	Err     error
}

AgentError Agent 自定义错误

func NewError

func NewError(code ErrorCode, message string) *AgentError

NewError 创建新的错误

func WrapError

func WrapError(code ErrorCode, message string, err error) *AgentError

WrapError 包装现有错误

func (*AgentError) Error

func (e *AgentError) Error() string

func (*AgentError) Unwrap

func (e *AgentError) Unwrap() error

type ErrorCode

type ErrorCode string

ErrorCode 错误代码类型

const (
	// 通用错误
	ErrCodeUnknown        ErrorCode = "UNKNOWN"
	ErrCodeInvalidRequest ErrorCode = "INVALID_REQUEST"
	ErrCodeNotFound       ErrorCode = "NOT_FOUND"
	ErrCodeInternal       ErrorCode = "INTERNAL_ERROR"

	// 服务相关错误
	ErrCodeServiceNotFound       ErrorCode = "SERVICE_NOT_FOUND"
	ErrCodeServiceNotRunning     ErrorCode = "SERVICE_NOT_RUNNING"
	ErrCodeServiceAlreadyRunning ErrorCode = "SERVICE_ALREADY_RUNNING"
	ErrCodeServiceStartFailed    ErrorCode = "SERVICE_START_FAILED"
	ErrCodeServiceStopFailed     ErrorCode = "SERVICE_STOP_FAILED"

	// 健康检查相关错误
	ErrCodeHealthCheckFailed  ErrorCode = "HEALTH_CHECK_FAILED"
	ErrCodeHealthCheckTimeout ErrorCode = "HEALTH_CHECK_TIMEOUT"

	// 配置相关错误
	ErrCodeConfigInvalid  ErrorCode = "CONFIG_INVALID"
	ErrCodeConfigNotFound ErrorCode = "CONFIG_NOT_FOUND"
)

Jump to

Keyboard shortcuts

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