{"record":{"id":"cc9b592f35262f1b","repo":"geekcomputers/Python","slug":"player-bust","errorCode":null,"errorMessage":"Player BUST","messagePattern":"Player BUST","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"BlackJack_game/blackjack_simulate.py","lineNumber":550,"sourceCode":"                prompt=\"Insurance amount >> \",\n                general_err=err,\n            )\n            self.player.chips.insurance = pay_ins\n\n        if self.choice == \"Double-down\":\n            try:\n                self.player.chips.double_bet()\n            except ValueError as e:\n                print(e)\n        self.player.refresh_prompt()\n        if self.choice in (\"Insurance\", \"Double-down\", \"Surrender\"):\n            self.go_on = False\n\n    def card_manage(self):\n        if self.choice in (\"Hit\", \"Double-down\"):\n            self.player.obtain_card(self.deck)\n            if self.player.is_point(\">\", BLACK_JACK):\n                raise ValueError(\"Player BUST\")\n            else:\n                self.dealer.strategy_trigger(self.deck)\n                if self.dealer.is_point(\">\", BLACK_JACK):\n                    raise ValueError(\"Dealer BUST\")\n        elif self.choice != \"Surrender\":\n            if not self.player.chips.is_insurance:\n                self.dealer.strategy_trigger(self.deck)\n                if self.dealer.is_point(\">\", BLACK_JACK):\n                    raise ValueError(\"Dealer BUST\")\n\n        self.dealer.showing()\n        self.player.showing()\n        if self.choice in (\"Double-down\", \"Stand\"):\n            self.go_on = False\n\n    def is_surrender(self):\n        if self.choice == \"Surrender\":\n            self.player.speak(\"Sorry, I surrender....\\n\")","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/geekcomputers/Python/blob/40f4cd2652d75ef8e49d76e5c4d431d458712719/BlackJack_game/blackjack_simulate.py#L532-L568","documentation":"Raised in card_manage when the player draws a card (Hit or Double-down) and their point total exceeds BLACK_JACK (21). It is control flow used to end the round with a player bust, not an infrastructure failure. The caller (play) is expected to catch it and settle the bet.","triggerScenarios":"self.choice in ('Hit','Double-down') followed by player.obtain_card(deck) making player.is_point('>', 21) true. Card_manage is invoked from play after each player decision.","commonSituations":"Simulating many rounds where a hit on a stiff hand (12-16) exceeds 21; forgetting that Double-down also draws a card and can bust.","solutions":["Catch ValueError in the calling play loop and settle the round as a player loss","Before hitting, check the current total and consider standing on 17+","Use is_point to inspect the hand total before requesting Hit/Double-down"],"exampleFix":"// before\nself.card_manage()\n// after\ntry:\n    self.card_manage()\nexcept ValueError as e:\n    # round ends: player bust, settle bet\n    self.settle(busted=str(e))","handlingStrategy":"try-catch","validationCode":"if choice in ('Hit','Double-down') and player.is_point('>', BLACK_JACK - 5):\n    # risky draw ahead; consider standing\n    pass","typeGuard":null,"tryCatchPattern":"try:\n    self.card_manage()\nexcept ValueError as e:\n    if 'Player BUST' in str(e):\n        self.settle(player_wins=False)","preventionTips":["Wrap every card_manage call in the play loop with try/except ValueError","Treat bust errors as round outcomes, not failures","Settle bets and reset state inside the handler before the next round"],"tags":["blackjack","bust","game-logic","value-error"],"backgroundTag":"game-round-end-condition","analyzedSha":"40f4cd2652d75ef8e49d76e5c4d431d458712719","analyzedAt":"2026-08-27T11:12:20.313Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}