From 31218060db80c2be8b6b22beebd48ec3b54a2532 Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Wed, 21 Jun 2023 12:49:22 +0200 Subject: [PATCH] ProjectOptionValueError: displays the config option description (#4674) ProjectOptionValueError: display the config option description It gives a bit more context of the problem for the user. Example message with the description included: `Error: Invalid value: 'invalid_debug_mode' is not one of 'always', 'modified', 'manual'. for option `debug_load_mode` (Allows one to control when PlatformIO should load debugging firmware to the end target) in section [env:nodemcu]` Co-authored-by: Ivan Kravets --- platformio/project/config.py | 11 +++++++++-- platformio/project/exception.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/platformio/project/config.py b/platformio/project/config.py index 2cb982fb..4e1a6673 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -324,6 +324,7 @@ class ProjectConfigBase: f"`${{this.__env__}}` is called from the `{parent_section}` " "section that is not valid PlatformIO environment, see", option, + " ", section, ) return parent_section[4:] @@ -332,7 +333,10 @@ class ProjectConfigBase: value = self.get(section, option) except RecursionError as exc: raise exception.ProjectOptionValueError( - "Infinite recursion has been detected", option, section + "Infinite recursion has been detected", + option, + " ", + section, ) from exc if isinstance(value, list): return "\n".join(value) @@ -359,7 +363,10 @@ class ProjectConfigBase: if not self.expand_interpolations: return value raise exception.ProjectOptionValueError( - exc.format_message(), option, section + exc.format_message(), + option, + " (%s) " % option_meta.description, + section, ) @staticmethod diff --git a/platformio/project/exception.py b/platformio/project/exception.py index d6e53fa6..91fc10bc 100644 --- a/platformio/project/exception.py +++ b/platformio/project/exception.py @@ -51,4 +51,4 @@ class InvalidEnvNameError(ProjectError): class ProjectOptionValueError(ProjectError): - MESSAGE = "{0} for option `{1}` in section [{2}]" + MESSAGE = "{0} for option `{1}`{2}in section [{3}]"