Documentation
¶
Index ¶
- func AddProxy(sub *model.Subscription, autotest bool, lazy bool, clashType model.ClashType, ...)
- func AppendRules(sub *model.Subscription, rules ...string)
- func AppenddRuleProvider(sub *model.Subscription, providerName string, group string, ...)
- func BuildSub(clashType model.ClashType, query model.ConvertConfig, template string, ...) (*model.Subscription, error)
- func FetchSubscriptionFromAPI(url string, userAgent string, retryTimes int) ([]byte, error)
- func FetchSubscriptionUserInfo(url string, userAgent string, retryTimes int) (string, error)
- func GetContryName(countryKey string) string
- func IsErrorCode(err error, code ErrorCode) bool
- func LoadSubscription(url string, refresh bool, userAgent string, cacheExpire int64, retryTimes int) ([]byte, error)
- func LoadTemplate(templatePath string) ([]byte, error)
- func MKDir(dir string) error
- func MergeSubAndTemplate(temp *model.Subscription, sub *model.Subscription, igcg bool)
- func MkEssentialDir() error
- func PrependRuleProvider(sub *model.Subscription, providerName string, group string, ...)
- func PrependRules(sub *model.Subscription, rules ...string)
- func RandomString(length int) string
- func Request(retryTimes int) *resty.Client
- type CommonError
- func NewDatabaseConnectError(cause error) *CommonError
- func NewDirAccessError(dirPath string, cause error) *CommonError
- func NewDirCreationError(dirPath string, cause error) *CommonError
- func NewError(code ErrorCode, message string, cause error) *CommonError
- func NewFileCreateError(filePath string, cause error) *CommonError
- func NewFileNotFoundError(filePath string) *CommonError
- func NewFileReadError(filePath string, cause error) *CommonError
- func NewFileWriteError(filePath string, cause error) *CommonError
- func NewInvalidInputError(paramName string, value string) *CommonError
- func NewNetworkRequestError(url string, cause error) *CommonError
- func NewNetworkResponseError(message string, cause error) *CommonError
- func NewRecordNotFoundError(recordType string, id string) *CommonError
- func NewRegexCompileError(pattern string, cause error) *CommonError
- func NewRegexInvalidError(paramName string, cause error) *CommonError
- func NewSimpleError(code ErrorCode, message string) *CommonError
- func NewSubscriptionLoadError(url string, cause error) *CommonError
- func NewSubscriptionParseError(cause error) *CommonError
- func NewTemplateLoadError(template string, cause error) *CommonError
- func NewTemplateParseError(cause error) *CommonError
- func NewValidationError(field string, message string) *CommonError
- type ErrorCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendRules ¶
func AppendRules(sub *model.Subscription, rules ...string)
func AppenddRuleProvider ¶
func AppenddRuleProvider( sub *model.Subscription, providerName string, group string, provider model.RuleProvider, )
func BuildSub ¶
func BuildSub(clashType model.ClashType, query model.ConvertConfig, template string, cacheExpire int64, retryTimes int) ( *model.Subscription, error, )
func GetContryName ¶
func IsErrorCode ¶
IsErrorCode checks if an error has a specific error code
func LoadSubscription ¶
func LoadTemplate ¶
func MergeSubAndTemplate ¶
func MergeSubAndTemplate(temp *model.Subscription, sub *model.Subscription, igcg bool)
func MkEssentialDir ¶
func MkEssentialDir() error
func PrependRuleProvider ¶
func PrependRuleProvider( sub *model.Subscription, providerName string, group string, provider model.RuleProvider, )
func PrependRules ¶
func PrependRules(sub *model.Subscription, rules ...string)
func RandomString ¶
Types ¶
type CommonError ¶
CommonError represents a structured error type for the common package
func NewDatabaseConnectError ¶
func NewDatabaseConnectError(cause error) *CommonError
Database errors
func NewDirAccessError ¶
func NewDirAccessError(dirPath string, cause error) *CommonError
func NewDirCreationError ¶
func NewDirCreationError(dirPath string, cause error) *CommonError
Directory errors
func NewError ¶
func NewError(code ErrorCode, message string, cause error) *CommonError
NewError creates a new CommonError
func NewFileCreateError ¶
func NewFileCreateError(filePath string, cause error) *CommonError
func NewFileReadError ¶
func NewFileReadError(filePath string, cause error) *CommonError
func NewFileWriteError ¶
func NewFileWriteError(filePath string, cause error) *CommonError
func NewInvalidInputError ¶
func NewInvalidInputError(paramName string, value string) *CommonError
func NewNetworkRequestError ¶
func NewNetworkRequestError(url string, cause error) *CommonError
Network errors
func NewNetworkResponseError ¶
func NewNetworkResponseError(message string, cause error) *CommonError
func NewRecordNotFoundError ¶
func NewRecordNotFoundError(recordType string, id string) *CommonError
func NewRegexCompileError ¶
func NewRegexCompileError(pattern string, cause error) *CommonError
Regex errors
func NewRegexInvalidError ¶
func NewRegexInvalidError(paramName string, cause error) *CommonError
func NewSimpleError ¶
func NewSimpleError(code ErrorCode, message string) *CommonError
NewSimpleError creates a new CommonError without a cause
func NewSubscriptionLoadError ¶
func NewSubscriptionLoadError(url string, cause error) *CommonError
Subscription errors
func NewSubscriptionParseError ¶
func NewSubscriptionParseError(cause error) *CommonError
func NewTemplateLoadError ¶
func NewTemplateLoadError(template string, cause error) *CommonError
Template errors
func NewTemplateParseError ¶
func NewTemplateParseError(cause error) *CommonError
func NewValidationError ¶
func NewValidationError(field string, message string) *CommonError
Validation errors
func (*CommonError) Error ¶
func (e *CommonError) Error() string
Error returns the string representation of the error
func (*CommonError) Unwrap ¶
func (e *CommonError) Unwrap() error
Unwrap returns the underlying error
type ErrorCode ¶
type ErrorCode string
ErrorCode represents different types of errors
const ( // Directory operation errors ErrDirCreation ErrorCode = "DIRECTORY_CREATION_FAILED" ErrDirAccess ErrorCode = "DIRECTORY_ACCESS_FAILED" // File operation errors ErrFileNotFound ErrorCode = "FILE_NOT_FOUND" ErrFileRead ErrorCode = "FILE_READ_FAILED" ErrFileWrite ErrorCode = "FILE_WRITE_FAILED" ErrFileCreate ErrorCode = "FILE_CREATE_FAILED" // Network operation errors ErrNetworkRequest ErrorCode = "NETWORK_REQUEST_FAILED" ErrNetworkResponse ErrorCode = "NETWORK_RESPONSE_FAILED" // Template and configuration errors ErrTemplateLoad ErrorCode = "TEMPLATE_LOAD_FAILED" ErrTemplateParse ErrorCode = "TEMPLATE_PARSE_FAILED" ErrConfigInvalid ErrorCode = "CONFIG_INVALID" // Subscription errors ErrSubscriptionLoad ErrorCode = "SUBSCRIPTION_LOAD_FAILED" ErrSubscriptionParse ErrorCode = "SUBSCRIPTION_PARSE_FAILED" // Regex errors ErrRegexCompile ErrorCode = "REGEX_COMPILE_FAILED" ErrRegexInvalid ErrorCode = "REGEX_INVALID" // Database errors ErrDatabaseConnect ErrorCode = "DATABASE_CONNECTION_FAILED" ErrDatabaseQuery ErrorCode = "DATABASE_QUERY_FAILED" ErrRecordNotFound ErrorCode = "RECORD_NOT_FOUND" // Validation errors ErrValidation ErrorCode = "VALIDATION_FAILED" ErrInvalidInput ErrorCode = "INVALID_INPUT" )
func GetErrorCode ¶
GetErrorCode extracts the error code from an error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.