Documentation
¶
Overview ¶
Package errors provides the unified error system for the fingerprint project. This is the canonical error package — all error codes, sentinel errors, error types, and helper functions live here. modules/core/errors.go re-exports a subset for backward compatibility.
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 IsCoreError(err error) bool
- func IsErrorCode(err error, code ErrorCode) 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 CoreError
- func NewCodedError(code ErrorCode, op string, err error) *CoreError
- func NewCodedErrorf(code ErrorCode, op, format string, args ...interface{}) *CoreError
- func NewCoreError(op string, err error) *CoreError
- func NewCoreErrorWithContext(op, context string, err error) *CoreError
- func WrapError(code ErrorCode, op string, err error, context string) *CoreError
- func WrapErrorf(code ErrorCode, op string, err error, format string, args ...interface{}) *CoreError
- 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") )
var ( // ErrInvalidProfile invalid fingerprint profile ErrInvalidProfile = errors.New("invalid fingerprint profile") // ErrInvalidJA3Hash invalid JA3 hash ErrInvalidJA3Hash = errors.New("invalid JA3 hash") // ErrInvalidJA4Hash invalid JA4 hash ErrInvalidJA4Hash = errors.New("invalid JA4 hash") // ErrFeatureExtractionFailed feature extraction failed ErrFeatureExtractionFailed = errors.New("feature extraction failed") // ErrClassificationFailed classification failed ErrClassificationFailed = errors.New("classification failed") // ErrRiskAssessmentFailed risk assessment failed ErrRiskAssessmentFailed = errors.New("risk assessment failed") // ErrNilPointer nil pointer dereference ErrNilPointer = errors.New("nil pointer dereference") // ErrOutOfRange value out of range ErrOutOfRange = errors.New("value out of range") // ErrEmptyValue empty value ErrEmptyValue = errors.New("empty value") // ErrAlreadyExists resource already exists ErrAlreadyExists = errors.New("already exists") )
Functions ¶
func IsClientHelloSpecNotImplemented ¶
IsClientHelloSpecNotImplemented checks if error indicates profile does not implement ClientHelloSpec.
func IsConfigError ¶
IsConfigError checks if it is a configuration error
func IsCoreError ¶ added in v1.0.11
IsCoreError checks if the error is a CoreError
func IsErrorCode ¶ added in v1.0.11
IsErrorCode checks if the error has the specified error code
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 CoreError ¶ added in v1.0.11
CoreError is a structured error type with error code, operation, and context
func NewCodedError ¶ added in v1.0.11
NewCodedError creates a CoreError with error code
func NewCodedErrorf ¶ added in v1.0.11
NewCodedErrorf creates a CoreError with formatted context
func NewCoreError ¶ added in v1.0.11
NewCoreError creates a new CoreError with operation and underlying error
func NewCoreErrorWithContext ¶ added in v1.0.11
NewCoreErrorWithContext creates a CoreError with context
func WrapErrorf ¶ added in v1.0.11
func WrapErrorf(code ErrorCode, op string, err error, format string, args ...interface{}) *CoreError
WrapErrorf wraps an error with formatted context
func (*CoreError) CoreCategory ¶ added in v1.0.11
CoreCategory returns the error category string
func (*CoreError) CoreHTTPStatus ¶ added in v1.0.11
CoreHTTPStatus returns the HTTP status code for this 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" )
const ( // Validation errors (VAL001-VAL099) ErrCodeInvalidInput ErrorCode = "VAL001" ErrCodeRequiredField ErrorCode = "VAL002" ErrCodeInvalidFormat ErrorCode = "VAL003" ErrCodeOutOfRange ErrorCode = "VAL004" ErrCodeNilPointer ErrorCode = "VAL005" ErrCodeInvalidType ErrorCode = "VAL006" ErrCodeEmptyValue ErrorCode = "VAL007" ErrCodeInvalidLength ErrorCode = "VAL008" ErrCodeInvalidCharset ErrorCode = "VAL009" ErrCodeInvalidPattern ErrorCode = "VAL010" // Not Found errors (NTF001-NTF099) ErrCodeProfileNTF ErrorCode = "NTF001" ErrCodeResourceNTF ErrorCode = "NTF002" ErrCodeKeyNTF ErrorCode = "NTF003" ErrCodeFileNTF ErrorCode = "NTF004" ErrCodeRouteNTF ErrorCode = "NTF005" // Security errors (SEC001-SEC099) ErrCodeSecurityError ErrorCode = "SEC001" ErrCodeAuthFailed ErrorCode = "SEC002" ErrCodeForbidden ErrorCode = "SEC004" ErrCodeInvalidToken ErrorCode = "SEC005" ErrCodeReplayAttack ErrorCode = "SEC006" ErrCodeFingerprintMismatch ErrorCode = "SEC007" ErrCodeInvalidTLSVersion ErrorCode = "SEC008" ErrCodeInvalidJA3Hash ErrorCode = "SEC009" ErrCodeInvalidJA4Hash ErrorCode = "SEC010" )
func GetErrorCode ¶ added in v1.0.11
GetErrorCode returns the ErrorCode from a CoreError, or empty string
func (ErrorCode) HTTPStatus ¶ added in v1.0.11
HTTPStatus returns the HTTP status code for the error code category