Documentation
¶
Index ¶
- Variables
- func As(err error, target interface{}) bool
- func Is(err, target error) bool
- func IsClientHelloSpecNotImplemented(err error) bool
- func IsCode(err error, code ErrorCode) 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 CodeError
- func ConfigNotLoaded(path string) *CodeError
- func Internal(op string, cause error) *CodeError
- func InvalidInput(field string, reason string) *CodeError
- func NewError(code ErrorCode, message string) *CodeError
- func NewErrorWithCause(code ErrorCode, message string, cause error) *CodeError
- func ProfileInvalid(id string, reason string) *CodeError
- func ProfileNotFound(id string) *CodeError
- func ProfileRemoveDefault(id string) *CodeError
- func RequiredField(field string) *CodeError
- func Timeout(op string, duration any) *CodeError
- type ErrorCategory
- type ErrorCode
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // configuration related errors 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") // configuration center errors 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") // network related errors ErrInvalidIP = errors.New("invalid IP address") ErrInvalidPort = errors.New("invalid port") ErrConnectionFailed = errors.New("connection failed") // protocol related errors ErrInvalidTLSVersion = errors.New("invalid TLS version") ErrInvalidCipherSuite = errors.New("invalid cipher suite") ErrInvalidExtension = errors.New("invalid extension") // input validation errors ErrInvalidInput = errors.New("invalid input") ErrEmptyInput = errors.New("empty input") ErrInputTooLarge = errors.New("input too large") ErrRequiredField = errors.New("required field is missing") // internal errors ErrInternal = errors.New("internal error") ErrNotImplemented = errors.New("not implemented") ErrTimeout = errors.New("operation timeout") ErrCancelled = errors.New("operation cancelled") )
Functions ¶
func IsClientHelloSpecNotImplemented ¶
IsClientHelloSpecNotImplemented checks if error indicates profile does not implement ClientHelloSpec.
func IsConfigError ¶
IsConfigError checks if it is a configuration error
func IsInvalidInput ¶
IsInvalidInput checks if it is an "invalid input" error
func NewConfigError ¶
NewConfigError createconfigurationerror
func NewNetworkError ¶
NewNetworkError creates network error
func NewNotFoundError ¶
NewNotFoundError creates not found error
func NewProtocolError ¶
NewProtocolError createprotocolerror
func NewValidationError ¶
NewValidationError createverifyerror
Types ¶
type CategorizedError ¶
type CategorizedError struct {
Category ErrorCategory
Err error
Details string
}
CategorizedError categorized error
func NewCategorizedError ¶
func NewCategorizedError(category ErrorCategory, err error, details string) *CategorizedError
NewCategorizedError creates categorized error
Example ¶
ExampleNewCategorizedError example:classifyerror
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 CodeError ¶ added in v1.0.6
CodeError error with error code
func ConfigNotLoaded ¶ added in v1.0.6
ConfigNotLoaded creates configuration not loaded error
func InvalidInput ¶ added in v1.0.6
InvalidInput creates invalid input error
func NewErrorWithCause ¶ added in v1.0.6
NewErrorWithCause creates error with error code and cause
func ProfileInvalid ¶ added in v1.0.6
ProfileInvalid creates Profile invalid error
func ProfileNotFound ¶ added in v1.0.6
ProfileNotFound creates Profile not found error
func ProfileRemoveDefault ¶ added in v1.0.6
ProfileRemoveDefault creates error for cannot remove default Profile
func RequiredField ¶ added in v1.0.6
RequiredField creates required field missing error
type ErrorCategory ¶
type ErrorCategory string
ErrorCategory errorclassify
const ( CategoryConfig ErrorCategory = "config" CategoryNetwork ErrorCategory = "network" CategoryProtocol ErrorCategory = "protocol" CategoryInput ErrorCategory = "input" CategoryInternal ErrorCategory = "internal" CategoryNotFound ErrorCategory = "not_found" )
type ErrorCode ¶ added in v1.0.6
type ErrorCode string
ErrorCode error code type
const ( // system level errors (SYS) ErrCodeSystem ErrorCode = "SYS001" ErrCodeNotFound ErrorCode = "SYS002" ErrCodeInvalidArg ErrorCode = "SYS003" ErrCodeTimeout ErrorCode = "SYS004" ErrCodeCancelled ErrorCode = "SYS005" ErrCodeInternal ErrorCode = "SYS006" ErrCodeNotImpl ErrorCode = "SYS007" // Profile related errors (PRF) ErrCodeProfileNotFound ErrorCode = "PRF001" ErrCodeProfileInvalid ErrorCode = "PRF002" ErrCodeProfileExists ErrorCode = "PRF003" ErrCodeProfileLoadFailed ErrorCode = "PRF004" ErrCodeProfileSaveFailed ErrorCode = "PRF005" ErrCodeProfileNoDefault ErrorCode = "PRF006" ErrCodeProfileRemoveDefault ErrorCode = "PRF007" // configuration related errors (CFG) ErrCodeConfigNotLoaded ErrorCode = "CFG001" ErrCodeConfigValidation ErrorCode = "CFG002" ErrCodeConfigPathNotFound ErrorCode = "CFG003" ErrCodeConfigExists ErrorCode = "CFG004" ErrCodeConfigVersion ErrorCode = "CFG005" // network related errors (NET) ErrCodeNetInvalidIP ErrorCode = "NET001" ErrCodeNetInvalidPort ErrorCode = "NET002" ErrCodeNetConnect ErrorCode = "NET003" ErrCodeNetTimeout ErrorCode = "NET004" // protocol related errors (PRT) ErrCodeProtoTLSVersion ErrorCode = "PRT001" ErrCodeProtoCipherSuite ErrorCode = "PRT002" ErrCodeProtoExtension ErrorCode = "PRT003" ErrCodeProtoInvalidSpec ErrorCode = "PRT004" // input validation errors (INP) ErrCodeInputInvalid ErrorCode = "INP001" ErrCodeInputEmpty ErrorCode = "INP002" ErrCodeInputTooLarge ErrorCode = "INP003" ErrCodeInputRequired ErrorCode = "INP004" // cache related errors (CCH) ErrCodeCacheNotFound ErrorCode = "CCH001" ErrCodeCacheExpired ErrorCode = "CCH002" // ML related errors (ML) ErrCodeMLModelNotFound ErrorCode = "ML001" ErrCodeMLPrediction ErrorCode = "ML002" // plugin related errors (PLG) ErrCodePluginNotFound ErrorCode = "PLG001" ErrCodePluginInit ErrorCode = "PLG002" )