chore: Remove the need for explicit bubble up of certain exceptions (#29235)

This commit is contained in:
John Bodley
2024-06-13 09:36:59 -07:00
committed by GitHub
parent f185bbed3c
commit daf37cbe58
4 changed files with 25 additions and 14 deletions

View File

@@ -45,15 +45,19 @@ class CreateSSHTunnelCommand(BaseCommand):
self._database = database
def run(self) -> Model:
"""
Create an SSH tunnel.
:returns: The SSH tunnel model
:raises SSHTunnelCreateFailedError: If the model creation fails
:raises SSHTunnelInvalidError: If the configuration are invalid
"""
try:
self.validate()
ssh_tunnel = SSHTunnelDAO.create(attributes=self._properties, commit=False)
return ssh_tunnel
return SSHTunnelDAO.create(attributes=self._properties, commit=False)
except DAOCreateFailedError as ex:
raise SSHTunnelCreateFailedError() from ex
except SSHTunnelInvalidError: # pylint: disable=try-except-raise
# Make sure to bubble this up
raise
def validate(self) -> None:
# TODO(hughhh): check to make sure the server port is not localhost