diff --git a/README.md b/README.md index 8c80dc0..e5fd3f9 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,10 @@ Installation Screen Shots ------------ -![Project Overview](https://wakatime.com/static/img/ScreenShots/ScreenShot-2014-10-29.png) \ No newline at end of file +![Project Overview](https://wakatime.com/static/img/ScreenShots/ScreenShot-2014-10-29.png) + +Contributing +------------ +**TO DO** + +1. Implement logging diff --git a/WakaTimeConstants.cs b/WakaTimeConstants.cs index 7f61975..cf5d1e6 100644 --- a/WakaTimeConstants.cs +++ b/WakaTimeConstants.cs @@ -5,7 +5,7 @@ namespace WakaTime { internal static class WakaTimeConstants - { + { internal const string CliUrl = "https://github.com/wakatime/wakatime/archive/master.zip"; internal const string PluginName = "ssms-wakatime"; internal const string EditorName = "ssms"; @@ -15,20 +15,30 @@ internal static class WakaTimeConstants { var regex = new Regex(@"(__version_info__ = )(\(( ?\'[0-9]\'\,?){3}\))"); var client = new WebClient(); - var about = client.DownloadString("https://raw.githubusercontent.com/wakatime/wakatime/master/wakatime/__about__.py"); - var match = regex.Match(about); - - if (!match.Success) + try { - Logger.Warning("Couldn't auto resolve wakatime cli version"); - return string.Empty; - } + var about = client.DownloadString("https://raw.githubusercontent.com/wakatime/wakatime/master/wakatime/__about__.py"); + var match = regex.Match(about); + + if (!match.Success) + { + Logger.Warning("Couldn't auto resolve wakatime cli version"); + return string.Empty; + } - var grp1 = match.Groups[2]; - var regexVersion = new Regex("([0-9])"); - var match2 = regexVersion.Matches(grp1.Value); + var grp1 = match.Groups[2]; + var regexVersion = new Regex("([0-9])"); + var match2 = regexVersion.Matches(grp1.Value); - return string.Format("{0}.{1}.{2}", match2[0].Value, match2[1].Value, match2[2].Value); + return string.Format("{0}.{1}.{2}", match2[0].Value, match2[1].Value, match2[2].Value); + } + catch (Exception ex) + { + { + Logger.Error("Exception when checking current wakatime cli version: ", ex); + return string.Empty; + } + } }; } } \ No newline at end of file