瀏覽代碼

增加异常捕获

陈国伟 3 年之前
父節點
當前提交
519c4d8e80
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      FastGithub/AppHostedService.cs

+ 10 - 3
FastGithub/AppHostedService.cs

@@ -68,10 +68,17 @@ namespace FastGithub
         {
             if (OperatingSystem.IsWindows() == false)
             {
-                if (await this.UseFastGithubProxyAsync() == false)
+                try
                 {
-                    var httpProxyPort = this.fastGithubOptions.Value.HttpProxyPort;
-                    this.logger.LogWarning($"请设置系统自动代理为http://{IPAddress.Loopback}:{httpProxyPort},或手动代理http/https为{IPAddress.Loopback}:{httpProxyPort}");
+                    if (await this.UseFastGithubProxyAsync() == false)
+                    {
+                        var httpProxyPort = this.fastGithubOptions.Value.HttpProxyPort;
+                        this.logger.LogWarning($"请设置系统自动代理为http://{IPAddress.Loopback}:{httpProxyPort},或手动代理http/https为{IPAddress.Loopback}:{httpProxyPort}");
+                    }
+                }
+                catch (Exception)
+                {
+                    this.logger.LogWarning("尝试获取代理信息失败");
                 }
             }
         }