Skip to content

Commit

Permalink
bug fix: handle validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Aug 18, 2024
1 parent 03fb7ab commit 50102c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import traceback
from asyncio import Queue

from pydantic import ValidationError
from sqlalchemy.exc import OperationalError
from sqlalchemy.ext.asyncio import AsyncSession

from _cache import SimpleALRUCache
from _kafka import consumer, producer
from app.controllers.player import PlayerController
Expand All @@ -16,8 +20,6 @@
convert_stg_to_kafka_report,
)
from database.database import get_session
from sqlalchemy.exc import OperationalError
from sqlalchemy.ext.asyncio import AsyncSession

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -180,6 +182,10 @@ async def process_data(report_queue: Queue, player_cache: SimpleALRUCache):
report = await process_msg_v2(msg=msg)
except (ReporterDoesNotExist, ReportedDoesNotExist):
continue
# pydantic error
except ValidationError as e:
logger.error({"error": e})
# database error
except OperationalError as e:
await error_queue.put(raw_msg)
logger.error({"error": e})
Expand Down

0 comments on commit 50102c4

Please sign in to comment.