diff --git a/PlexRequests.Api/ApiRequest.cs b/PlexRequests.Api/ApiRequest.cs index ad056fbfe..1b7975462 100644 --- a/PlexRequests.Api/ApiRequest.cs +++ b/PlexRequests.Api/ApiRequest.cs @@ -92,18 +92,10 @@ namespace PlexRequests.Api throw new ApplicationException(message, response.ErrorException); } - try - { - var json = JsonConvert.DeserializeObject(response.Content); - return json; - } - catch (Exception e) - { - Log.Error(e); - Log.Error(response.Content); - throw; - } + var json = JsonConvert.DeserializeObject(response.Content); + + return json; } private T DeserializeXml(string input) diff --git a/PlexRequests.Api/SonarrApi.cs b/PlexRequests.Api/SonarrApi.cs index d70ba2eef..f9d68da31 100644 --- a/PlexRequests.Api/SonarrApi.cs +++ b/PlexRequests.Api/SonarrApi.cs @@ -27,6 +27,9 @@ using System; using System.Collections.Generic; using System.Linq; + +using Newtonsoft.Json; + using NLog; using PlexRequests.Api.Interfaces; using PlexRequests.Api.Models.Sonarr; @@ -93,15 +96,19 @@ namespace PlexRequests.Api request.AddHeader("X-Api-Key", apiKey); request.AddJsonBody(options); - var obj = Api.ExecuteJson(request, baseUrl); - - if (obj == null) + SonarrAddSeries result; + try { + result = Api.ExecuteJson(request, baseUrl); + } + catch (JsonSerializationException jse) + { + Log.Error(jse); var error = Api.ExecuteJson(request, baseUrl); - obj = new SonarrAddSeries { ErrorMessage = error.errorMessage }; + result = new SonarrAddSeries { ErrorMessage = error.errorMessage }; } - return obj; + return result; } public SystemStatus SystemStatus(string apiKey, Uri baseUrl)