From 460d295a66b0b01989d2e86773f21effc1729e7f Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Fri, 30 Apr 2021 17:01:11 +0800 Subject: [PATCH] Refactor TryReleaseTcpPort Process.MainModule.FileName null handling --- Netch/Controllers/MainController.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Netch/Controllers/MainController.cs b/Netch/Controllers/MainController.cs index 220e92a4..2a0c340e 100644 --- a/Netch/Controllers/MainController.cs +++ b/Netch/Controllers/MainController.cs @@ -187,16 +187,9 @@ namespace Netch.Controllers { foreach (var p in PortHelper.GetProcessByUsedTcpPort(port)) { - string fileName; - try - { - fileName = p.MainModule?.FileName ?? throw new Exception(); // TODO what's this exception? - } - catch (Exception e) - { - Global.Logger.Warning(e.ToString()); + var fileName = p.MainModule?.FileName; + if (fileName == null) continue; - } if (fileName.StartsWith(Global.NetchDir)) {