From aa0f8433757e80b4d6b5523cab0c477af1a2ec75 Mon Sep 17 00:00:00 2001 From: Roeniss Moon Date: Wed, 6 Mar 2024 02:45:51 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B5=AC=EB=A7=A4=20=EC=8B=A4=ED=8C=A8?= =?UTF-8?q?=20=EC=8B=9C=20=EC=9D=B4=EC=9C=A0=EB=A5=BC=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dhapi/port/lottery_client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dhapi/port/lottery_client.py b/src/dhapi/port/lottery_client.py index 863f390..5064e08 100644 --- a/src/dhapi/port/lottery_client.py +++ b/src/dhapi/port/lottery_client.py @@ -124,10 +124,18 @@ def buy_lotto645(self, tickets: List[Lotto645Ticket]): logger.debug(f"response: {response_text}") response = json.loads(response_text) + if not self._is_purchase_success(response): + raise RuntimeError(f"❗ 로또6/45 구매에 실패했습니다. (사유: {response['result']['resultMsg']})") + slots = self._format_lotto_numbers(response["result"]["arrGameChoiceNum"]) self._lottery_endpoint.print_result_of_buy_lotto645(slots) + except RuntimeError as e: + raise e except Exception: - raise RuntimeError("❗ 로또6/45 구매에 실패했습니다.") + raise RuntimeError("❗ 로또6/45 구매에 실패했습니다. (사유: 알 수 없는 오류)") + + def _is_purchase_success(self, response): + return response["result"]["resultCode"] == "100" def _make_buy_loyyo645_param(self, tickets: List[Lotto645Ticket]): params = []