浏览代码

Add improved error error for #2141

Bond-009 5 年之前
父节点
当前提交
a4ca259a64
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      Emby.Server.Implementations/LiveTv/LiveTvManager.cs

+ 6 - 3
Emby.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -304,9 +304,12 @@ namespace Emby.Server.Implementations.LiveTv
         }
 
         private ILiveTvService GetService(string name)
-        {
-            return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
-        }
+            => Array.Find(_services, x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase))
+                ?? throw new KeyNotFoundException(
+                    string.Format(
+                        CultureInfo.InvariantCulture,
+                        "No service with the name '{0}' can be found.",
+                        name));
 
         private static void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
         {