# Buggy code
def handle_exception(self, msg, exc):
    if isinstance(exc, SaltCloudException):
        # It's a know exception an we know own to handle it
        if isinstance(exc, SaltCloudSystemExit):
            # This is a salt cloud system exit
            if exc.exit_code > 0:
                # the exit code is bigger than 0, it's an error
                msg = "Error: {0}".format(msg)
            self.exit(exc.exit_code, "{0}\n".format(msg.format(str(exc).rstrip())))
        # It's not a system exit but it's an error we can
        # handle
        self.error(msg.format(str(exc)))
    # This is a generic exception, log it, include traceback if
    # debug logging is enabled and exit.
    log.error(
        msg.format(exc),
        # Show the traceback if the debug logging level is
        # enabled
        exc_info_on_loglevel=logging.DEBUG,
    )
    self.exit(salt.defaults.exitcodes.EX_GENERIC)


# Traceback (salt.exceptions.SaltCloudSystemExit)
# salt-cloud -m map_lxc_test
[INFO    ] salt-cloud starting
No minions matched the target. No command was sent, no jid was assigned.
No minions matched the target. No command was sent, no jid was assigned.
[INFO    ] Runner completed: 20150513153526561971
[INFO    ] Runner completed: 20150513153527922468
[INFO    ] Runner completed: 20150513153528777523
[INFO    ] Runner completed: 20150513153529730576
[INFO    ] Runner completed: 20150513153530693758
[INFO    ] Runner completed: 20150513153531631134
[INFO    ] Runner completed: 20150513153532586328
[INFO    ] Runner completed: 20150513153533544745
[INFO    ] Runner completed: 20150513153534447523
[INFO    ] Runner completed: 20150513153535369341
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
SaltCloudSystemExit: Configured provider ursa-lxc:lxc minion: ursa is unreachable
Traceback (most recent call last):
File "/usr/bin/salt-cloud", line 10, in <module>
salt_cloud()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 316, in salt_cloud
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cloud/cli.py", line 86, in run
mapper = salt.cloud.Map(self.config)
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1557, in __init__
Cloud.__init__(self, opts)
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 478, in __init__
self.__filter_non_working_providers()
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1536, in __filter_non_working_providers
if self.clouds[fun]() is False:
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/lxc.py", line 501, in get_configured_provider
__active_provider_name__, data['target']))
SaltCloudSystemExit: Configured provider ursa-lxc:lxc minion: ursa is unreachable
Traceback (most recent call last):
File "/usr/bin/salt-cloud", line 10, in <module>
salt_cloud()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 316, in salt_cloud
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cloud/cli.py", line 86, in run
mapper = salt.cloud.Map(self.config)
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1557, in __init__
Cloud.__init__(self, opts)
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 478, in __init__
self.__filter_non_working_providers()
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1536, in __filter_non_working_providers
if self.clouds[fun]() is False:
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/lxc.py", line 501, in get_configured_provider
__active_provider_name__, data['target']))
salt.exceptions.SaltCloudSystemExit: Configured provider ursa-lxc:lxc minion: ursa is unreachable
# salt-run --versions-report
Salt: 2015.5.0
Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
Jinja2: 2.7.2
M2Crypto: 0.21.1
msgpack-python: 0.3.0
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: Not Installed
PyYAML: 3.10
ioflo: Not Installed
PyZMQ: 14.0.1
RAET: Not Installed
ZMQ: 4.0.4
Mako: 0.9.1
Debian source package: 2015.5.0+ds-1trusty1

# Fixed code
def handle_exception(self, msg, exc):
    if isinstance(exc, SaltCloudException):
        # It's a known exception and we know how to handle it
        if isinstance(exc, SaltCloudSystemExit):
            # This is a salt cloud system exit
            if exc.exit_code > 0:
                # the exit code is bigger than 0, it's an error
                msg = "Error: {0}".format(msg)
            self.exit(exc.exit_code, "{0}\n".format(msg.format(str(exc).rstrip())))
        # It's not a system exit but it's an error we can
        # handle
        self.error(msg.format(str(exc)))
    # This is a generic exception, log it, include traceback if
    # debug logging is enabled and exit.
    log.error(
        msg.format(exc),
        # Show the traceback if the debug logging level is
        # enabled
        exc_info_on_loglevel=logging.DEBUG,
    )
    self.exit(salt.defaults.exitcodes.EX_GENERIC)