From ea6ae85f7a37bc34f02c33cc15f062b73646fe4c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 14 Nov 2015 22:34:56 -0800 Subject: [PATCH] Fixed: Logging invalid version when failing to connect to Kodi Closes #927 --- .../Notifications/Xbmc/XbmcService.cs | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs index 9dc913929..20a9d7f26 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net; using FluentValidation.Results; using Newtonsoft.Json.Linq; using NLog; @@ -59,32 +60,27 @@ namespace NzbDrone.Core.Notifications.Xbmc private XbmcVersion GetJsonVersion(XbmcSettings settings) { - try + return _xbmcVersionCache.Get(settings.Address, () => { - return _xbmcVersionCache.Get(settings.Address, () => - { - - var response = _proxy.GetJsonVersion(settings); - - _logger.Debug("Getting version from response: " + response); - var result = Json.Deserialize>(response); + var response = _proxy.GetJsonVersion(settings); - var versionObject = result.Result.Property("version"); + _logger.Debug("Getting version from response: " + response); + var result = Json.Deserialize>(response); - if (versionObject.Value.Type == JTokenType.Integer) return new XbmcVersion((int) versionObject.Value); + var versionObject = result.Result.Property("version"); - if (versionObject.Value.Type == JTokenType.Object) return Json.Deserialize(versionObject.Value.ToString()); - - throw new InvalidCastException("Unknown Version structure!: " + versionObject); - }, TimeSpan.FromHours(12)); - } + if (versionObject.Value.Type == JTokenType.Integer) + { + return new XbmcVersion((int)versionObject.Value); + } - catch (Exception ex) - { - _logger.DebugException(ex.Message, ex); - } + if (versionObject.Value.Type == JTokenType.Object) + { + return Json.Deserialize(versionObject.Value.ToString()); + } - return new XbmcVersion(); + throw new InvalidCastException("Unknown Version structure!: " + versionObject); + }, TimeSpan.FromHours(12)); } private IApiProvider GetApiProvider(XbmcSettings settings)