question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to parse without getting exception for wrong format?

See original GitHub issue

I’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:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
twccleggcommented, Dec 8, 2022

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.

0reactions
twccleggcommented, Nov 28, 2022

Should there be TryParse and TryParseValid maybe?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found