1
0

Chore: more parse proxy group error detail

This commit is contained in:
Dreamacro 2023-04-04 16:49:42 +08:00
parent 5045ca4574
commit 4cd4912749

View File

@ -50,17 +50,17 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
providers := []types.ProxyProvider{} providers := []types.ProxyProvider{}
if len(groupOption.Proxies) == 0 && len(groupOption.Use) == 0 { if len(groupOption.Proxies) == 0 && len(groupOption.Use) == 0 {
return nil, errMissProxy return nil, fmt.Errorf("%s: %w", groupName, errMissProxy)
} }
if len(groupOption.Proxies) != 0 { if len(groupOption.Proxies) != 0 {
ps, err := getProxies(proxyMap, groupOption.Proxies) ps, err := getProxies(proxyMap, groupOption.Proxies)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("%s: %w", groupName, err)
} }
if _, ok := providersMap[groupName]; ok { if _, ok := providersMap[groupName]; ok {
return nil, errDuplicateProvider return nil, fmt.Errorf("%s: %w", groupName, errDuplicateProvider)
} }
// select don't need health check // select don't need health check
@ -68,20 +68,20 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
hc := provider.NewHealthCheck(ps, "", 0, true) hc := provider.NewHealthCheck(ps, "", 0, true)
pd, err := provider.NewCompatibleProvider(groupName, ps, hc) pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("%s: %w", groupName, err)
} }
providers = append(providers, pd) providers = append(providers, pd)
providersMap[groupName] = pd providersMap[groupName] = pd
} else { } else {
if groupOption.URL == "" || groupOption.Interval == 0 { if groupOption.URL == "" || groupOption.Interval == 0 {
return nil, errMissHealthCheck return nil, fmt.Errorf("%s: %w", groupName, errMissHealthCheck)
} }
hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.Interval), groupOption.Lazy) hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.Interval), groupOption.Lazy)
pd, err := provider.NewCompatibleProvider(groupName, ps, hc) pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("%s: %w", groupName, err)
} }
providers = append(providers, pd) providers = append(providers, pd)
@ -92,7 +92,7 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
if len(groupOption.Use) != 0 { if len(groupOption.Use) != 0 {
list, err := getProviders(providersMap, groupOption.Use) list, err := getProviders(providersMap, groupOption.Use)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("%s: %w", groupName, err)
} }
providers = append(providers, list...) providers = append(providers, list...)
} }
@ -112,7 +112,7 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
case "relay": case "relay":
group = NewRelay(groupOption, providers) group = NewRelay(groupOption, providers)
default: default:
return nil, fmt.Errorf("%w: %s", errType, groupOption.Type) return nil, fmt.Errorf("%s %w: %s", groupName, errType, groupOption.Type)
} }
return group, nil return group, nil