fix: narrow TryParse/TryParseValid catch to NumberParseException - #401
Closed
twcclegg wants to merge 1 commit into
Closed
fix: narrow TryParse/TryParseValid catch to NumberParseException#401twcclegg wants to merge 1 commit into
twcclegg wants to merge 1 commit into
Conversation
The bare catch in PhoneNumbers.Extensions.PhoneNumber swallowed every exception, not just parse failures, silently masking bugs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #401 +/- ##
=======================================
Coverage 77.26% 77.26%
=======================================
Files 39 39
Lines 4548 4548
Branches 1129 1129
=======================================
Hits 3514 3514
Misses 783 783
Partials 251 251 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4 tasks
Owner
Author
3 tasks
Owner
Author
|
Superseded by #405. |
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.
Summary
PhoneNumbers.Extensions.PhoneNumber.TryParse/TryParseValidused a barecatch { }, silently swallowing any exception (not just parse failures) and masking bugs.catch (NumberParseException), matching the exception typePhoneNumberUtil.Parseactually throws.Test plan
dotnet build csharp --no-restore— clean, 0 warnings/errorsdotnet test csharp/PhoneNumbers.slnx— 864 tests passed (net8.0 + net10.0), including the existingTryParse("1235557704", "ZX", ...)case that already exercises the narrowed exception path