Skip to content

Fix: catch IOException instead of all exceptions in retry logic#19

Open
HashidaTKS wants to merge 1 commit into
masterfrom
fix/exception-handling
Open

Fix: catch IOException instead of all exceptions in retry logic#19
HashidaTKS wants to merge 1 commit into
masterfrom
fix/exception-handling

Conversation

@HashidaTKS

Copy link
Copy Markdown
Owner

問題点

XmlSerializerWrapper.Serialize() 内の File.Replace / File.Move のリトライ処理で、例外型を指定しない catch {} を使用していた。

これにより OutOfMemoryExceptionThreadAbortException など、リトライしても解決しない例外まで吸収してしまい、また例外情報がログに残らないためデバッグが困難だった。

改善内容

  • catchcatch (IOException ex) に変更し、ファイルの一時的なロックが原因の場合にのみリトライするよう限定
  • リトライ前に LoggerWrapper.Warn(ex) でログを記録し、問題が発生した際に原因を追跡可能に

Test plan

  • IOException 発生時にリトライが実行されることを確認
  • IOException 以外の例外は catch されずそのままスローされることを確認
  • リトライ前にログが出力されることを確認

🤖 Generated with Claude Code

… retry

Bare catch{} was silently absorbing all exception types including
OutOfMemoryException, ThreadAbortException, etc. beyond what was intended.
Narrow the catch to IOException (the only case where a retry is meaningful),
and log the exception before retrying so failures are observable.

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