From 847cecaf7fe77413af4e675a4631f1db861ceaa9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 22 Mar 2019 16:12:06 +0100 Subject: [PATCH] [fix] Fix error message for bad choice for setting enums --- locales/en.json | 2 +- src/yunohost/settings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/en.json b/locales/en.json index 00fe6aa66..940201ef4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -199,7 +199,7 @@ "firewall_reloaded": "The firewall has been reloaded", "firewall_rules_cmd_failed": "Some firewall rules commands have failed. For more information, see the log.", "format_datetime_short": "%m/%d/%Y %I:%M %p", - "global_settings_bad_choice_for_enum": "Bad value for setting {setting:s}, received {received_type:s}, except {expected_type:s}", + "global_settings_bad_choice_for_enum": "Bad choice for setting {setting:s}, received '{choice:s}' but available choices are : {available_choices:s}", "global_settings_bad_type_for_setting": "Bad type for setting {setting:s}, received {received_type:s}, except {expected_type:s}", "global_settings_cant_open_settings": "Failed to open settings file, reason: {reason:s}", "global_settings_cant_serialize_settings": "Failed to serialize settings data, reason: {reason:s}", diff --git a/src/yunohost/settings.py b/src/yunohost/settings.py index 81ea46114..5d2d55ede 100644 --- a/src/yunohost/settings.py +++ b/src/yunohost/settings.py @@ -109,8 +109,8 @@ def settings_set(key, value): elif key_type == "enum": if value not in settings[key]["choices"]: raise YunohostError('global_settings_bad_choice_for_enum', setting=key, - received_type=type(value).__name__, - expected_type=", ".join(settings[key]["choices"])) + choice=value, + available_choices=", ".join(settings[key]["choices"])) else: raise YunohostError('global_settings_unknown_type', setting=key, unknown_type=key_type)