ansible/ansible — pull request #7095 by radeksimko (2014-04-21 15:00:53+00:00)
Title: Prevent catching unrelated exceptions

There are many places in the code where ansible simply catches all exceptions, which is a bad practice also called as [_Pokemon exception handling_](http://www.dodgycoder.net/2011/11/yoda-conditions-pokemon-exception.html).

I believe we can fine-grain most of them (as it's actually mentioned in [the coding guidelines](https://github.com/ansible/ansible/blob/devel/CODING_GUIDELINES.md#exceptions)) and this is the first place where it's actually already causing issues.

If the `module.run_command(...` will trigger `sys.exit()`, then `exceptions.SystemExit` will be catched by this statement too and if there was already a JSON output (`fail_json()` has been already called before exiting), it will end up in parse error on the output as two `fail_json()` calls will generate two unparsable concatenated JSON strings.

The erroneous situation can be simulated within #7094