Skip to content

Fix: add null checks for Payout_Detail_Table elements in GetRaceResult#28

Open
HashidaTKS wants to merge 1 commit into
masterfrom
fix/scraper-get-race-result-null-check
Open

Fix: add null checks for Payout_Detail_Table elements in GetRaceResult#28
HashidaTKS wants to merge 1 commit into
masterfrom
fix/scraper-get-race-result-null-check

Conversation

@HashidaTKS
Copy link
Copy Markdown
Owner

問題点

Scraper.GetRaceResult()GetElementsByClassName("Payout_Detail_Table").FirstOrDefault() の結果を null チェックせずに直接メソッドチェーンしていた。

ページ構造が変化した場合や払い戻し情報が存在しないレースの場合、FirstOrDefault()null を返し、直後の .GetElementsByClassName() 呼び出しで NullReferenceException が発生する。

また、各払い戻し情報(単勝・馬連・馬単など)取得でも同様に null チェックなしのメソッドチェーンが連続していた。

改善内容

  • firstPayoutTable / secondPayoutTable の null チェックを追加し、null の場合はログを出力して null を早期リターン
  • 各払い戻し情報取得の連鎖に ?. 演算子を使用
  • ワイドオッズの取得で null の場合は空のコレクションにフォールバック

Test plan

  • 通常のレース結果ページで払い戻し情報が正常に取得されることを確認
  • Payout_Detail_Table が存在しないページでも例外が発生せず null が返されることを確認

🤖 Generated with Claude Code

GetRaceResult accessed firstPayoutTable and secondPayoutTable without null
checks. If the page structure changes or the race result is unavailable,
GetElementsByClassName returns an empty collection and FirstOrDefault()
returns null, causing NullReferenceException on the next method call.

Add explicit null guards for the two table roots and use null-conditional
operators (?.) throughout the payout extraction chain. Return null early
with a log message when the page structure is unexpected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant