MCPcopy Create free account
hub / github.com/saltstack/salt / handle_exception

Method handle_exception

salt/cloud/cli.py:379–399  ·  view source on GitHub ↗
(self, msg, exc)

Source from the content-addressed store, hash-verified

377 return True
378
379 def handle_exception(self, msg, exc):
380 if isinstance(exc, SaltCloudException):
381 # It's a known exception and we know how to handle it
382 if isinstance(exc, SaltCloudSystemExit):
383 # This is a salt cloud system exit
384 if exc.exit_code > 0:
385 # the exit code is bigger than 0, it's an error
386 msg = f"Error: {msg}"
387 self.exit(exc.exit_code, msg.format(exc).rstrip() + "\n")
388 # It's not a system exit but it's an error we can
389 # handle
390 self.error(msg.format(exc))
391 # This is a generic exception, log it, include traceback if
392 # debug logging is enabled and exit.
393 log.error(
394 msg.format(exc),
395 # Show the traceback if the debug logging level is
396 # enabled
397 exc_info_on_loglevel=logging.DEBUG,
398 )
399 self.exit(salt.defaults.exitcodes.EX_GENERIC)

Callers 1

runMethod · 0.95

Calls 3

exitMethod · 0.80
formatMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected