Skip to content

catch only specific exceptions#1205

Merged
snuyanzin merged 1 commit intodatafaker-net:mainfrom
asolntsev:refactor/exception-handling
May 23, 2024
Merged

catch only specific exceptions#1205
snuyanzin merged 1 commit intodatafaker-net:mainfrom
asolntsev:refactor/exception-handling

Conversation

@asolntsev
Copy link
Collaborator

...instead of catching too generic exceptions (which is considered a bad practice because some unexpected problems might be ignored).

...instead of catching too generic exceptions (which is considered a bad practice because some unexpected problems might be ignored).
@what-the-diff
Copy link

what-the-diff bot commented May 23, 2024

PR Summary

  • Enhanced Code Imports
    This change extended the usage of java.time.format.DateTimeParseException to both EnZAIdNumber.java and SvSEIdNumber.java files. This helps in dealing with date and time related exceptions more effectively.

  • Improved Exception Handling
    An additional catch for IllegalArgumentException was added in FakerIDN.java to account for situations where argument inputs might not have been appropriate. This improves the robustness of the code, making it capable to smoothly handle diverse potential exceptions.

  • Streamlined Catch Statements
    Multiple catch statements in Relationship.java were replaced with a single line catch (IllegalAccessException | InvocationTargetException e). This makes the code cleaner and easier to read while still ensuring any exceptions are appropriately handled.

  • Enhanced Phone Number Testing
    Additional protection against unexpectedly formatted phone numbers has been added in PhoneNumberValidityFinderTest.java through the introduction of the NumberParseException catch block.

  • Updated Assertion Messages
    Assertions in RelationshipTest.java have been upgraded to display specific error messages for thrown exceptions. This makes debugging easier and improves the overall test feedback.

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.14%. Comparing base (b37c566) to head (82eec1a).
Report is 103 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1205      +/-   ##
============================================
- Coverage     92.35%   92.14%   -0.21%     
- Complexity     2821     2905      +84     
============================================
  Files           292      301       +9     
  Lines          5609     5745     +136     
  Branches        599      620      +21     
============================================
+ Hits           5180     5294     +114     
- Misses          275      293      +18     
- Partials        154      158       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@snuyanzin snuyanzin merged commit 9164492 into datafaker-net:main May 23, 2024
@asolntsev asolntsev deleted the refactor/exception-handling branch May 23, 2024 21:22
@asolntsev asolntsev self-assigned this May 26, 2024
@asolntsev asolntsev added the enhancement New feature or request label May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants