Documentation
¶
Index ¶
- Variables
- func As(err error, target interface{}) bool
- func Is(err, target error) bool
- func IsClientHelloSpecNotImplemented(err error) bool
- func IsConfigError(err error) bool
- func IsInvalidInput(err error) bool
- func IsNotFound(err error) bool
- func New(text string) error
- func NewConfigError(op string, err error) error
- func NewNetworkError(op string, err error) error
- func NewNotFoundError(resource string, identifier string) error
- func NewProtocolError(protocol string, err error) error
- func NewValidationError(field string, reason string) error
- func Newf(format string, args ...interface{}) error
- func Wrap(err error, context string) error
- func Wrapf(err error, format string, args ...interface{}) error
- type CategorizedError
- type ErrorCategory
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // 配置相关错误 ErrProfileNotFound = errors.New("profile not found") ErrInvalidFingerprint = errors.New("invalid fingerprint format") ErrClientHelloSpecNotImplemented = errors.New("client hello spec not implemented") ErrInvalidUserAgent = errors.New("invalid user agent") ErrNoProfilesAvailable = errors.New("no profiles available") ErrUnsupportedBrowser = errors.New("unsupported browser") // 配置中心错误 ErrConfigNotLoaded = errors.New("config not loaded") ErrConfigValidation = errors.New("config validation failed") ErrConfigPathNotFound = errors.New("config path not found") ErrConfigAlreadyExists = errors.New("config already exists") ErrVersionNotFound = errors.New("version not found") // 网络相关错误 ErrInvalidIP = errors.New("invalid IP address") ErrInvalidPort = errors.New("invalid port") ErrConnectionFailed = errors.New("connection failed") // 协议相关错误 ErrInvalidTLSVersion = errors.New("invalid TLS version") ErrInvalidCipherSuite = errors.New("invalid cipher suite") ErrInvalidExtension = errors.New("invalid extension") // 输入验证错误 ErrInvalidInput = errors.New("invalid input") ErrEmptyInput = errors.New("empty input") ErrInputTooLarge = errors.New("input too large") ErrRequiredField = errors.New("required field is missing") // 内部错误 ErrInternal = errors.New("internal error") ErrNotImplemented = errors.New("not implemented") ErrTimeout = errors.New("operation timeout") ErrCancelled = errors.New("operation cancelled") )
Functions ¶
func IsClientHelloSpecNotImplemented ¶
IsClientHelloSpecNotImplemented 判断错误是否表示 profile 未实现 ClientHelloSpec。
func NewNotFoundError ¶
NewNotFoundError 创建未找到错误
func NewProtocolError ¶
NewProtocolError 创建协议错误
func NewValidationError ¶
NewValidationError 创建验证错误
Types ¶
type CategorizedError ¶
type CategorizedError struct {
Category ErrorCategory
Err error
Details string
}
CategorizedError 带分类的错误
func NewCategorizedError ¶
func NewCategorizedError(category ErrorCategory, err error, details string) *CategorizedError
NewCategorizedError 创建带分类的错误
Example ¶
ExampleNewCategorizedError 示例:分类错误
err := NewCategorizedError(CategoryConfig, ErrConfigNotLoaded, "missing file") fmt.Println(err)
Output: [config] config not loaded: missing file
func (*CategorizedError) Error ¶
func (e *CategorizedError) Error() string
func (*CategorizedError) Unwrap ¶
func (e *CategorizedError) Unwrap() error
type ErrorCategory ¶
type ErrorCategory string
ErrorCategory 错误分类
const ( CategoryConfig ErrorCategory = "config" CategoryNetwork ErrorCategory = "network" CategoryProtocol ErrorCategory = "protocol" CategoryInput ErrorCategory = "input" CategoryInternal ErrorCategory = "internal" CategoryNotFound ErrorCategory = "not_found" )
Click to show internal directories.
Click to hide internal directories.