From: Stephen Toub Date: Tue, 11 Jun 2019 20:00:42 +0000 (-0700) Subject: Provide more exception details when PlatformDetection.ToVersion fails (dotnet/corefx... X-Git-Tag: submit/tizen/20210909.063632~11031^2~1329 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfcd9dbcb97383cc4a92437676f0bd0bdd9343c3;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Provide more exception details when PlatformDetection.ToVersion fails (dotnet/corefx#38463) Commit migrated from https://github.com/dotnet/corefx/commit/49b6ade10a35e44573da6e851bc09133d5922c0a --- diff --git a/src/libraries/CoreFx.Private.TestUtilities/src/System/PlatformDetection.Unix.cs b/src/libraries/CoreFx.Private.TestUtilities/src/System/PlatformDetection.Unix.cs index 541b417..bbcf9f5 100644 --- a/src/libraries/CoreFx.Private.TestUtilities/src/System/PlatformDetection.Unix.cs +++ b/src/libraries/CoreFx.Private.TestUtilities/src/System/PlatformDetection.Unix.cs @@ -157,12 +157,19 @@ namespace System static Version ToVersion(string versionString) { - if (versionString.IndexOf('.') != -1) - return new Version(versionString); + try + { + if (versionString.IndexOf('.') != -1) + return new Version(versionString); - // minor version is required by Version - // let's default it to 0 - return new Version(int.Parse(versionString), 0); + // minor version is required by Version + // let's default it to 0 + return new Version(int.Parse(versionString), 0); + } + catch (Exception exc) + { + throw new FormatException($"Failed to parse version string: '{versionString}'", exc); + } } private static (string name, Version version) GetDistroInfo() =>