{"record":{"id":"43b56c196e7a4f48","repo":"geekcomputers/Python","slug":"dealer-bust","errorCode":null,"errorMessage":"Dealer BUST","messagePattern":"Dealer BUST","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"BlackJack_game/blackjack_simulate.py","lineNumber":554,"sourceCode":"\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\")\n\n    def get_winner(self):\n        if self.bust:\n            return \"Dealer\" if self.player.is_point(\">\", BLACK_JACK) else \"Player\"","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/geekcomputers/Python/blob/40f4cd2652d75ef8e49d76e5c4d431d458712719/BlackJack_game/blackjack_simulate.py#L536-L572","documentation":"Raised in card_manage after the player successfully hits and the dealer's strategy_trigger draw pushes the dealer's total over 21. Signals the dealer busted, so the player wins the round. It is an expected game-outcome signal implemented as an exception.","triggerScenarios":"Player chooses Hit/Double-down, does not bust, then dealer.strategy_trigger(deck) draws cards per dealer rules until the dealer exceeds 21, triggering is_point('>', BLACK_JACK).","commonSituations":"Dealer forced to hit on 16 and drawing a face card; simulations that don't catch the error will abort the whole game loop.","solutions":["Catch ValueError around card_manage in the play loop and settle as a player win when the message is 'Dealer BUST'","Distinguish player vs dealer bust by inspecting the message or using separate exception types","Ensure the outer game loop continues to the next round after settlement"],"exampleFix":"// before\nself.card_manage()\n// after\ntry:\n    self.card_manage()\nexcept ValueError as e:\n    win = 'Dealer' in str(e)\n    self.settle(player_wins=win)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    self.card_manage()\nexcept ValueError as e:\n    if 'Dealer BUST' in str(e):\n        self.settle(player_wins=True)","preventionTips":["Catch ValueError around card_manage for both bust messages","Route all bust outcomes through one settlement function","Never let bust exceptions escape the per-round loop"],"tags":["blackjack","bust","dealer","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"}