Skip to content

Fix: throw ArgumentException in GetRegionType for unknown region names#31

Open
HashidaTKS wants to merge 1 commit into
masterfrom
fix/utility-get-region-type-null-safety
Open

Fix: throw ArgumentException in GetRegionType for unknown region names#31
HashidaTKS wants to merge 1 commit into
masterfrom
fix/utility-get-region-type-null-safety

Conversation

@HashidaTKS

Copy link
Copy Markdown
Owner

問題点

Utility.GetRegionType(string regionName)FirstOrDefault()null を返した場合、直後の .RagionType アクセスで NullReferenceException が発生していた。

どの値が問題だったかを示す情報がなく、デバッグが困難だった。

改善内容

  • FirstOrDefault() の結果を変数に受け取り null チェックを追加
  • 未知の地域名の場合は ArgumentException をスローして問題の地域名を明示

Test plan

  • 有効な地域名を渡した場合に正常に RegionType が返されることを確認
  • 未知の地域名を渡した場合に ArgumentException がスローされることを確認

🤖 Generated with Claude Code

… found

FirstOrDefault() returned null for unknown region names, and the immediate
.RagionType access caused a NullReferenceException with no context about
which value was invalid. Throw a descriptive ArgumentException instead so
callers get a clear error message pointing to the unknown region name.

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