Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 구매 실패 시 이유를 출력 #111

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/dhapi/port/lottery_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down