Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(key-value): remove redundant exception logging #21702

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion superset/key_value/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def run(self) -> Key:
return self.create()
except SQLAlchemyError as ex:
db.session.rollback()
logger.exception("Error running create command")
raise KeyValueCreateFailedError() from ex

def validate(self) -> None:
Expand Down
1 change: 0 additions & 1 deletion superset/key_value/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def run(self) -> bool:
return self.delete()
except SQLAlchemyError as ex:
db.session.rollback()
logger.exception("Error running delete command")
raise KeyValueDeleteFailedError() from ex

def validate(self) -> None:
Expand Down
1 change: 0 additions & 1 deletion superset/key_value/commands/delete_expired.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def run(self) -> None:
self.delete_expired()
except SQLAlchemyError as ex:
db.session.rollback()
logger.exception("Error running delete command")
raise KeyValueDeleteFailedError() from ex

def validate(self) -> None:
Expand Down
1 change: 0 additions & 1 deletion superset/key_value/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def run(self) -> Any:
try:
return self.get()
except SQLAlchemyError as ex:
logger.exception("Error running get command")
raise KeyValueGetFailedError() from ex

def validate(self) -> None:
Expand Down
1 change: 0 additions & 1 deletion superset/key_value/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def run(self) -> Optional[Key]:
return self.update()
except SQLAlchemyError as ex:
db.session.rollback()
logger.exception("Error running update command")
raise KeyValueUpdateFailedError() from ex

def validate(self) -> None:
Expand Down
11 changes: 7 additions & 4 deletions superset/key_value/commands/upsert.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
from superset import db
from superset.commands.base import BaseCommand
from superset.key_value.commands.create import CreateKeyValueCommand
from superset.key_value.exceptions import KeyValueUpdateFailedError
from superset.key_value.exceptions import (
KeyValueCreateFailedError,
KeyValueUpsertFailedError,
)
from superset.key_value.models import KeyValueEntry
from superset.key_value.types import Key, KeyValueResource
from superset.key_value.utils import get_filter
Expand Down Expand Up @@ -66,10 +69,9 @@ def __init__(
def run(self) -> Key:
try:
return self.upsert()
except SQLAlchemyError as ex:
except (KeyValueCreateFailedError, SQLAlchemyError) as ex:
db.session.rollback()
logger.exception("Error running update command")
raise KeyValueUpdateFailedError() from ex
raise KeyValueUpsertFailedError() from ex

def validate(self) -> None:
pass
Expand All @@ -90,6 +92,7 @@ def upsert(self) -> Key:
db.session.merge(entry)
db.session.commit()
return Key(entry.id, entry.uuid)

return CreateKeyValueCommand(
resource=self.resource,
value=self.value,
Expand Down
4 changes: 4 additions & 0 deletions superset/key_value/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ class KeyValueUpdateFailedError(UpdateFailedError):
message = _("An error occurred while updating the value.")


class KeyValueUpsertFailedError(UpdateFailedError):
message = _("An error occurred while upserting the value.")


class KeyValueAccessDeniedError(ForbiddenError):
message = _("You don't have permission to modify the value.")