fix(blackjack): return db_error on bet-commit failure; document new patterns
- do_blackjack_bet now wraps its _commit so a DB failure returns db_error (handled by the command layer) instead of raising through the interaction. - DEV_NOTES "Adding a New Economy Command" checklist updated: use effective_cooldown / store.ITEM_COOLDOWNS as the single source of truth for item-modified cooldowns, and handle db_error via reply_db_error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VbAVsrZuYesea99mPMmPT
This commit is contained in:
@@ -248,7 +248,12 @@ async def do_blackjack_bet(user_id: int, bet: int) -> dict:
|
||||
if user["balance"] < bet:
|
||||
return {"ok": False, "reason": "insufficient", "balance": user["balance"]}
|
||||
user["balance"] -= bet
|
||||
await _commit(user_id, user)
|
||||
try:
|
||||
await _commit(user_id, user)
|
||||
except DatabaseError:
|
||||
# Deduction never persisted, so the player was not charged - report it
|
||||
# instead of raising through the interaction handler.
|
||||
return {"ok": False, "reason": "db_error"}
|
||||
return {"ok": True, "balance": user["balance"]}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user