DEV: improve error message for invalid setting’s value

Before this fix we would display this exception:

```
Discourse::InvalidParameters:
  value
```

After this fix we will display:

```
Discourse::InvalidParameters:
  Invalid `x` value for `s3_region`
```
This commit is contained in:
jjaffeux 2021-06-17 15:24:35 +02:00 committed by Alan Guo Xiang Tan
parent ff6114d83f
commit dc63613c96
1 changed files with 1 additions and 1 deletions

View File

@ -204,7 +204,7 @@ class SiteSettings::TypeSupervisor
def validate_value(name, type, val)
if type == self.class.types[:enum]
if enum_class(name)
raise Discourse::InvalidParameters.new(:value) unless enum_class(name).valid_value?(val)
raise Discourse::InvalidParameters.new("Invalid `#{val}` value for `#{name}`") unless enum_class(name).valid_value?(val)
else
unless (choice = @choices[name])
raise Discourse::InvalidParameters.new(name)