Merge pull request #95446 from Ma27/improve-opt-not-defined-error

lib/modules: improve error-message for undeclared options if prefix contains no options
This commit is contained in:
Silvan Mosberger 2020-08-18 18:26:55 +02:00 committed by GitHub
commit f8962fd92e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,8 +115,19 @@ rec {
checkUnmatched =
if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
let firstDef = head merged.unmatchedDefns;
in throw "The option `${showOption (prefix ++ firstDef.prefix)}' defined in `${firstDef.file}' does not exist."
let
firstDef = head merged.unmatchedDefns;
baseMsg = "The option `${showOption (prefix ++ firstDef.prefix)}' defined in `${firstDef.file}' does not exist.";
in
if attrNames options == [ "_module" ]
then throw ''
${baseMsg}
However there are no options defined in `${showOption prefix}'. Are you sure you've
declared your options properly? This can happen if you e.g. declared your options in `types.submodule'
under `config' rather than `options'.
''
else throw baseMsg
else null;
result = builtins.seq checkUnmatched {