Better handling of SAB not returning json to addfile

Fixed: Handling of unexpected responses from SABnzbd when adding releases
This commit is contained in:
Mark McDowall
2013-11-19 21:47:26 -08:00
parent a01f2dd862
commit 4a7bd5b849
5 changed files with 60 additions and 10 deletions
+12
View File
@@ -41,6 +41,18 @@ namespace NzbDrone.Common.Serializer
return JsonConvert.DeserializeObject(json, type, SerializerSetting);
}
public static T TryDeserialize<T>(string json) where T : new()
{
try
{
return Deserialize<T>(json);
}
catch (JsonReaderException ex)
{
return default(T);
}
}
public static string ToJson(this object obj)
{
return JsonConvert.SerializeObject(obj, SerializerSetting);