chore: Remove the need for explicit bubble up of certain exceptions (#29235)
This commit is contained in:
parent
f185bbed3c
commit
daf37cbe58
|
|
@ -442,10 +442,15 @@ class ChartDataRestApi(ChartRestApi):
|
|||
def _create_query_context_from_form(
|
||||
self, form_data: dict[str, Any]
|
||||
) -> QueryContext:
|
||||
"""
|
||||
Create the query context from the form data.
|
||||
|
||||
:param form_data: The chart form data
|
||||
:returns: The query context
|
||||
:raises ValidationError: If the request is incorrect
|
||||
"""
|
||||
|
||||
try:
|
||||
return ChartDataQueryContextSchema().load(form_data)
|
||||
except KeyError as ex:
|
||||
raise ValidationError("Request is incorrect") from ex
|
||||
except ValidationError: # pylint: disable=try-except-raise
|
||||
# Make sure to bubble this up
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -51,13 +51,18 @@ def set_form_data(form_data: dict[str, Any]) -> None:
|
|||
|
||||
|
||||
def _create_query_context_from_form(form_data: dict[str, Any]) -> QueryContext:
|
||||
"""
|
||||
Create the query context from the form data.
|
||||
|
||||
:param form_data: The task form data
|
||||
:returns: The query context
|
||||
:raises ValidationError: If the request is incorrect
|
||||
"""
|
||||
|
||||
try:
|
||||
return ChartDataQueryContextSchema().load(form_data)
|
||||
except KeyError as ex:
|
||||
raise ValidationError("Request is incorrect") from ex
|
||||
except ValidationError: # pylint: disable=try-except-raise
|
||||
# Make sure to bubble this up
|
||||
raise
|
||||
|
||||
|
||||
def _load_user_from_job_metadata(job_metadata: dict[str, Any]) -> User:
|
||||
|
|
|
|||
|
|
@ -146,9 +146,6 @@ def stats_timing(stats_key: str, stats_logger: BaseStatsLogger) -> Iterator[floa
|
|||
start_ts = now_as_float()
|
||||
try:
|
||||
yield start_ts
|
||||
except Exception: # pylint: disable=try-except-raise
|
||||
# Make sure to bubble this up
|
||||
raise
|
||||
finally:
|
||||
stats_logger.timing(stats_key, now_as_float() - start_ts)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue