chore(settings): clearer error message for surfshark regions
- only log possible 'new' server regions - do not log old retro-compatible server regions - maintains compatibility with older names
This commit is contained in:
@@ -166,9 +166,12 @@ func getLocationFilterChoices(vpnServiceProvider string,
|
|||||||
if vpnServiceProvider == providers.Surfshark {
|
if vpnServiceProvider == providers.Surfshark {
|
||||||
// // Retro compatibility
|
// // Retro compatibility
|
||||||
// TODO v4 remove
|
// TODO v4 remove
|
||||||
filterChoices.Regions = append(filterChoices.Regions, validation.SurfsharkRetroLocChoices()...)
|
newAndRetroRegions := append(filterChoices.Regions, validation.SurfsharkRetroLocChoices()...) //nolint:gocritic
|
||||||
err := validate.AreAllOneOfCaseInsensitive(ss.Regions, filterChoices.Regions)
|
err := validate.AreAllOneOfCaseInsensitive(ss.Regions, newAndRetroRegions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Only return error comparing with newer regions, we don't want to confuse the user
|
||||||
|
// with the retro regions in the error message.
|
||||||
|
err = validate.AreAllOneOfCaseInsensitive(ss.Regions, filterChoices.Regions)
|
||||||
return models.FilterChoices{}, fmt.Errorf("%w: %w", ErrRegionNotValid, err)
|
return models.FilterChoices{}, fmt.Errorf("%w: %w", ErrRegionNotValid, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user