1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-26 22:46:53 -04:00

Error handling in migration to new quality

This commit is contained in:
Mark McDowall
2014-02-04 18:46:03 -08:00
parent fe4f3d5d1e
commit c9a77e99a0
3 changed files with 25 additions and 11 deletions
+10 -3
View File
@@ -41,15 +41,22 @@ namespace NzbDrone.Common.Serializer
return JsonConvert.DeserializeObject(json, type, SerializerSetting);
}
public static T TryDeserialize<T>(string json) where T : new()
public static bool TryDeserialize<T>(string json, out T result) where T : new()
{
try
{
return Deserialize<T>(json);
result = Deserialize<T>(json);
return true;
}
catch (JsonReaderException ex)
{
return default(T);
result = default(T);
return false;
}
catch (JsonSerializationException ex)
{
result = default(T);
return false;
}
}