saltstack/salt — pull request #16339 by cachedout (2014-10-02 21:50:21+00:00)
Title: Module failure reporting

This introduces a new system that allows modules to report the reason that they could not be loaded and to return that data to the user instead of a generic error message. Use of this this new functionality allows module writers to return sane error messages to users about their dependencies instead of forcing them to examine ```__virtual___``` to determine the reason for an unloaded module.

Below is some sample code demonstrating a module using this behaviour:

```
def __virtual__():
return False, ['So go the gods of war', 'Lo, I am thunderstruck']

def charge():
return 'Charge!'
```

And the output displayed to the user:

```
mp@silver ...Devel/salt/tests % sudo salt silver battle.charge()
silver:
'battle.charge' is not available. Possible reasons: ['So go the gods of war', 'Lo, I am thunderstruck']
```

As one can see, a ```__virtual__``` function can now optionally return a list of reasons that a module could not be loaded. This allows a module author to progressively test for dependencies and populate the error list as appropriate.