Closed M-Zuber closed 9 years ago
Thank you for your report.
You are right, TryPase
should not throw any exceptions, and Parse
should not throw any exceptions except FormatException
.
So I fixed it at 8ddb11f, and publish new NuGet package ( https://www.nuget.org/packages/IPAddressRange/ ).
Thanks!
What I meant in my question about TryParse
was should the catch
in TryParse
be changed from:
catch(FormatException`)
to
catch
Yea, that's right, but if fix only TryParse
, Parse
method keep throw IndexOutOfRange
exception.
So, I deside fix Parse
method ( more exactly, fix internal implements at constractor).
But, you mean, I should be prepare for happen to unexpected type of exception?
Well, I understand that I should implemet in TryParse
catch all types of exception not only FormatException
.
I'll consider it well. Let me have few days.
What is the desired action if someone passes in the following ipcidr:
128.139.251.57/3212
?The first
Regex
matches, but then anIndexOutOfRangeException
is thrown when trying to build theBitMask
. If we where to make the firstRegex
stricter, there would still be a problem as this string also passes theRegex
for anetmask
.-as an aside: should it be considered to let the
TryParse
catch more than justFormatException
?