Don't raise bare Exceptions
It's generally recommended that base Exceptions not be raised, because this makes it impossible to handle exceptions in a more granular way. except Exception: will catch all exceptions, not just the one you might care about. This replaces most instances of this pattern in tripleoclient, with the exception of the one in overcloud_image.py because I have a separate change open that already fixes it. Change-Id: I6fce306c4ffc57b4c52389be1feb583f5a400a64
This commit is contained in:
parent
f5ef4434b0
commit
d7141d6f51
|
@ -36,11 +36,15 @@ class NotFound(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class DeploymentError(Exception):
|
||||
class DeploymentError(RuntimeError):
|
||||
"""Deployment failed"""
|
||||
pass
|
||||
|
||||
|
||||
class RootUserExecution(Exception):
|
||||
"""Command was executed by a root user"""
|
||||
|
||||
|
||||
class InvalidConfiguration(ValueError):
|
||||
"""Invalid parameters were specified for the deployment"""
|
||||
pass
|
||||
|
|
|
@ -143,8 +143,9 @@ class DeployOvercloud(command.Command):
|
|||
number_controllers = int(parameters.get('ControllerCount', 0))
|
||||
if number_controllers > 1:
|
||||
if not args.ntp_server:
|
||||
raise Exception('Specify --ntp-server when using multiple'
|
||||
' controllers (with HA).')
|
||||
raise exceptions.InvalidConfiguration(
|
||||
'Specify --ntp-server when using multiple controllers '
|
||||
'(with HA).')
|
||||
|
||||
parameters.update({
|
||||
'NeutronL3HA': True,
|
||||
|
@ -260,9 +261,9 @@ class DeployOvercloud(command.Command):
|
|||
orchestration_client, stack_name)
|
||||
if not create_result:
|
||||
if stack is None:
|
||||
raise Exception("Heat Stack create failed.")
|
||||
raise exceptions.DeploymentError("Heat Stack create failed.")
|
||||
else:
|
||||
raise Exception("Heat Stack update failed.")
|
||||
raise exceptions.DeploymentError("Heat Stack update failed.")
|
||||
|
||||
def _pre_heat_deploy(self):
|
||||
"""Setup before the Heat stack create or update has been done."""
|
||||
|
|
Loading…
Reference in New Issue