Added try-catch for DateTime.TryParse edgecase

closes #3518
This commit is contained in:
Taloth Saldono 2020-02-09 17:05:45 +01:00
parent fc5dd8137f
commit 51e2e084af
2 changed files with 36 additions and 4 deletions

View File

@ -21,7 +21,15 @@ namespace NzbDrone.Core.SeriesStats
{
DateTime nextAiring;
if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null;
try
{
if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null;
}
catch (ArgumentOutOfRangeException)
{
// GHI 3518: Can throw on mono (6.x?) despite being a Try*
return null;
}
return nextAiring;
}
@ -33,7 +41,15 @@ namespace NzbDrone.Core.SeriesStats
{
DateTime previousAiring;
if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null;
try
{
if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null;
}
catch (ArgumentOutOfRangeException)
{
// GHI 3518: Can throw on mono (6.x?) despite being a Try*
return null;
}
return previousAiring;
}

View File

@ -21,7 +21,15 @@ namespace NzbDrone.Core.SeriesStats
{
DateTime nextAiring;
if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null;
try
{
if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null;
}
catch (ArgumentOutOfRangeException)
{
// GHI 3518: Can throw on mono (6.x?) despite being a Try*
return null;
}
return nextAiring;
}
@ -33,7 +41,15 @@ namespace NzbDrone.Core.SeriesStats
{
DateTime previousAiring;
if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null;
try
{
if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null;
}
catch (ArgumentOutOfRangeException)
{
// GHI 3518: Can throw on mono (6.x?) despite being a Try*
return null;
}
return previousAiring;
}