Repository navigation
Report an out-of-range number for an option as a usage error [patch] - #70
Merged
Merged
Conversation
int.Parse and its relatives throw OverflowException, not FormatException, for a number too large for the type, so `--count 99999999999` escaped TryApplyOptions as an unhandled exception and the tool exited 134 instead of printing the usage error and exiting 2. Fixes #69 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5LUHQ94WSDTYRpSJV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5LUHQ94WSDTYRpSJV
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



TryApplyOptionsturned a value handler's exception into the usage error only forFormatExceptionandArgumentException. The most natural handler,v => count = int.Parse(v, CultureInfo.InvariantCulture), throwsOverflowExceptionfor99999999999. That exception escaped and the tool crashed with exit 134 instead of printing the usage line and exiting 2. The same applies tolong.Parse,byte.Parse,decimal.Parseandcheckedconversions.Change
TrayAppBuilder.TryApplyOptionsalso treatsOverflowExceptionas a usage error.OverflowExceptiontoo.I kept the explicit list rather than catching every non-fatal exception, so a handler bug such as a
NullReferenceExceptionstill surfaces as a bug rather than as "bad input".Tests
TryApplyOptions_WhenAHandlerParsesAnOutOfRangeNumber_ReportsItAsAUsageErroruses a realint.Parsehandler with--count 99999999999, and expectsfalseplus the overflow message.OverflowException. With it, the suite passes: 161 passed, plus 1 skipped that is platform-gated (DesktopSession_OffLinux_IsAlwaysAvailable).Fixes #69
Generated by Claude Code