Skip to content

Commit 86003e4

Browse files
committed
replace exceptions
1 parent 83bfca1 commit 86003e4

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

services/payments/src/simcore_service_payments/db/payments_methods_repo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import datetime
22

3-
import simcore_postgres_database.aiopg_errors as db_errors
43
import sqlalchemy as sa
54
from arrow import utcnow
65
from models_library.api_schemas_payments.errors import (
@@ -16,6 +15,7 @@
1615
InitPromptAckFlowState,
1716
payments_methods,
1817
)
18+
from sqlalchemy.exc import IntegrityError
1919

2020
from ..models.db import PaymentsMethodsDB
2121
from .base import BaseRepository
@@ -42,7 +42,7 @@ async def insert_init_payment_method(
4242
)
4343
return payment_method_id
4444

45-
except db_errors.UniqueViolation as err:
45+
except IntegrityError as err:
4646
raise PaymentMethodUniqueViolationError(
4747
payment_method_id=payment_method_id
4848
) from err

services/payments/src/simcore_service_payments/db/payments_transactions_repo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
from models_library.users import UserID
1414
from models_library.wallets import WalletID
1515
from pydantic import HttpUrl, PositiveInt, TypeAdapter
16-
from simcore_postgres_database import aiopg_errors as pg_errors
1716
from simcore_postgres_database.models.payments_transactions import (
1817
PaymentTransactionState,
1918
payments_transactions,
2019
)
20+
from sqlalchemy.exc import IntegrityError
2121

2222
from ..models.db import PaymentsTransactionsDB
2323
from .base import BaseRepository
@@ -58,7 +58,7 @@ async def insert_init_payment_transaction(
5858
)
5959
)
6060
return payment_id
61-
except pg_errors.UniqueViolation as exc:
61+
except IntegrityError as exc:
6262
raise PaymentAlreadyExistsError(payment_id=f"{payment_id}") from exc
6363

6464
async def update_ack_payment_transaction(

services/web/server/src/simcore_service_webserver/garbage_collector/_core_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from models_library.groups import Group, GroupID, GroupType
66
from models_library.projects import ProjectID
77
from models_library.users import UserID
8-
from simcore_postgres_database.aiopg_errors import DatabaseError
8+
from simcore_postgres_database.aiopg_errors import DatabaseError as AiopgDatabaseError
9+
from sqlalchemy.exc import DatabaseError
910

1011
from ..groups.api import get_group_by_gid
1112
from ..projects._projects_repository_legacy import (
@@ -187,8 +188,8 @@ async def replace_current_owner(
187188
)
188189

189190
except (
191+
AiopgDatabaseError,
190192
DatabaseError,
191-
asyncpg.exceptions.PostgresError,
192193
ProjectNotFoundError,
193194
UserNotFoundError,
194195
):

services/web/server/src/simcore_service_webserver/security/_authz_policy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
from models_library.products import ProductName
1616
from models_library.users import UserID
1717
from servicelib.aiohttp.db_asyncpg_engine import get_async_engine
18-
from simcore_postgres_database.aiopg_errors import DatabaseError as AiopgDatabaseError
19-
from sqlalchemy.exc import DatabaseError as SQLAlchemyDatabaseError
18+
from sqlalchemy.exc import DatabaseError
2019

2120
from . import _authz_repository
2221
from ._authz_access_model import (
@@ -48,7 +47,7 @@
4847
def _handle_exceptions_as_503():
4948
try:
5049
yield
51-
except (AiopgDatabaseError, SQLAlchemyDatabaseError) as err:
50+
except DatabaseError as err:
5251
_logger.exception(
5352
**create_troubleshooting_log_kwargs(
5453
"Auth unavailable due to database error",

0 commit comments

Comments
 (0)