How to parse without getting exception for wrong format?
See original GitHub issueI’m getting a phone number input from the user. So I try to parse it using the Parse
method of PhoneNumberUtil
. If the number format is incorrect then it will throw an exception. But I don’t want to get an exception. I want something like TryParse
which will return a boolean containing success or failure. Is there an easy to achieve this behavior?
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Why does SimpleDateFormat.parse not throw an exception ...
SimpleDateFormat is lenient by default and won't throw exceptions even though the format of the date given might not match the format its ......
Read more >How to Handle the NumberFormat Exception in Java
The NumberFormatException is an unchecked exception in Java that occurs when an attempt is made to convert a string with an incorrect format...
Read more >FormatException Class (System)
The exception that is thrown when the format of an argument is invalid, or when a composite format string is not well formed....
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >Error System.FormatException Int64.Parse Input string was ...
I installed a GoogleAnalytics SDK and the Facebook SDK in Unity 2017.2.0.3f ... FormatException: Input string was not in the correct format.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Feel free to give https://www.nuget.org/packages/libphonenumber-csharp.extensions/8.13.2-alpha1 a shot, any comments or review of #164 is welcome.
Should there be
TryParse
andTryParseValid
maybe?