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 <me@ikravets.com>
This commit is contained in:
Dawid Nowak
2023-06-21 12:49:22 +02:00
committed by GitHub
parent e25b170b34
commit 31218060db
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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}]"