From bb9bcf6cdfbd34e1be7fb059adf5227bac7062a6 Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Thu, 23 Jun 2022 15:05:45 -0400 Subject: [PATCH] feat: TimeZone getting an invalid time zone now throws exception with time zone name --- ICD.Common.Utils/TimeZoneInfo/IcdTimeZoneInfo.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ICD.Common.Utils/TimeZoneInfo/IcdTimeZoneInfo.cs b/ICD.Common.Utils/TimeZoneInfo/IcdTimeZoneInfo.cs index 5d15110..0203101 100644 --- a/ICD.Common.Utils/TimeZoneInfo/IcdTimeZoneInfo.cs +++ b/ICD.Common.Utils/TimeZoneInfo/IcdTimeZoneInfo.cs @@ -61,7 +61,11 @@ namespace ICD.Common.Utils.TimeZoneInfo public static IcdTimeZoneInfo FindSystemTimeZoneById(string timeZoneId) { - return s_Cache[timeZoneId]; + IcdTimeZoneInfo timeZone; + if (s_Cache.TryGetValue(timeZoneId, out timeZone)) + return timeZone; + + throw new KeyNotFoundException(string.Format("Unable to find timezone with id:{0}", timeZoneId)); } public static bool TryFindSystemTimeZoneById(string timeZoneId, out IcdTimeZoneInfo output)