mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Improve error message when module does not exist
This also simplifies the if/elif/else logic when the module does not exist. The else would never be reached anyway since we are doing an ``if X is not None`` followed by an ``if X is None``. Fixes #22958
This commit is contained in:
parent
6b694e3495
commit
d0d7a5481c
1 changed files with 6 additions and 5 deletions
|
@ -776,14 +776,15 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
'''
|
||||
mod_name = function_name.split('.')[0]
|
||||
if mod_name in self.loaded_modules:
|
||||
return '{0!r} is not available.'.format(function_name)
|
||||
return '\'{0}\' is not available.'.format(function_name)
|
||||
else:
|
||||
if self.missing_modules.get(mod_name) is not None:
|
||||
return '\'{0}\' __virtual__ returned False: {1}'.format(mod_name, self.missing_modules[mod_name])
|
||||
elif self.missing_modules.get(mod_name) is None:
|
||||
return '\'{0}\' __virtual__ returned False'.format(mod_name)
|
||||
# Error in the __virtual__ function of an existing module
|
||||
return '\'{0}\' __virtual__ returned False: {1}'.format(
|
||||
mod_name, self.missing_modules[mod_name]
|
||||
)
|
||||
else:
|
||||
return '\'{0}\' is not available.'.format(function_name)
|
||||
return 'Module \'{0}\' is not available.'.format(mod_name)
|
||||
|
||||
def refresh_file_mapping(self):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue