-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated IllegalArgumentException to NullPointerException for Null Values in Require Class #11162
Conversation
Update IllegealStateException to NullPointerException as the exception misleads in debugging.
Update Require.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please share the motivation for this pull request? The goal of Require
is to check if the arguments passed are valid or not, and checking for nulls is a subset of those validations.
Hi, I was getting error as Input should be Set for the nonNull method and could not identify the root cause of the issue and took a while for figuring out that the value is null. Method name says nonNull and it throws illegalargumentexception. Atleast the exception should be null or the message should say the value is null. That is the reason for this pull request Thanks, |
Can you share the code that caused you to get that exception? |
i was doing creating new webdriverwait but did not realize the driver passed in the class was null. When i run the code i got illegalargumentexception with Input must be set error and did not have clue on what's happening. On further investigation i found the mistake but that error was confusing. This is just a cosmetic change i'm proposing.. I was passing the wait as below. |
looks like everything that doesn't include
It would make sense for some of these to be more clear what the problem is, but I don't think everything should be changed to |
Got it.. just my thoughts.. if not needed also fine.. I know the problem now. |
I strongly beleive this method should be fixed atleast.
public static double positive(String argName, Double number, String message) { |
I was agreeing with you, then I realized I was using a bad example.... The fix that needs to happen is that the logic for
needs to match the logic for
i.e., the |
I actually understand the logic now.. i was confused. |
Updated the above
Updated the above logic in the pull request... What can i do to make this more readable for null values?? We can leave it as it is? |
I think we just have to know that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @vinoth959!
Codecov ReportBase: 52.28% // Head: 52.28% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## trunk #11162 +/- ##
=======================================
Coverage 52.28% 52.28%
=======================================
Files 81 81
Lines 5499 5499
Branches 198 198
=======================================
Hits 2875 2875
Misses 2426 2426
Partials 198 198 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Kudos, SonarCloud Quality Gate passed! |
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Update IllegalArgumentException to NullPointerException for Null Values.
Description
Updated IllegalArgumentException to NullPointerException for Null Values in Require.java file.
Changed MustBeSet to MustBePositive for one condition based on the action in the Require class.
Motivation and Context
Misleading Exception and cause issues in debugging.
Types of changes
Checklist
Updated IllegalArgumentException to NullPointerException for Null Values.
Changed MustBeSet to MustBePositive for one condition based on the action in Require Class.