整理了错误的捕捉

关闭窗口验证
This commit is contained in:
2025-07-10 18:00:31 +08:00
parent fdd321e635
commit 4e8c66aa38
17 changed files with 368 additions and 95 deletions

View File

@@ -96,7 +96,7 @@ namespace CapMachine.Wpf
var IsOK = SoftAuthorizeHelper.CheckLience(MachineCode, PublicKey, Lience);
if (!IsOK)
{
LogService.Error("授权失败");
LogService.Info("授权失败");
//this.Shutdown();
}
}
@@ -130,7 +130,7 @@ namespace CapMachine.Wpf
//containerRegistry.RegisterSingleton<MachineDataService>();
containerRegistry.RegisterSingleton<CanDriveService>();
containerRegistry.RegisterSingleton<CanFdDriveService>();
containerRegistry.RegisterSingleton<LinDriveService>();
containerRegistry.RegisterSingleton<MachineRtDataService>();
containerRegistry.RegisterSingleton<DataRecordService>();
@@ -289,7 +289,7 @@ namespace CapMachine.Wpf
//给当前的全局异常捕捉服务使用
LogService = ContainerLocator.Container.Resolve<ILogService>();
LogService.Error("Start-->OnInitialized");
LogService.Info("程序启动");
base.OnInitialized();
//#endregion
@@ -317,7 +317,7 @@ namespace CapMachine.Wpf
void App_Exit(object sender, ExitEventArgs e)
{
//程序退出时需要处理的业务
LogService.Error("程序退出");
LogService.Info("App-程序退出");
}
@@ -332,12 +332,14 @@ namespace CapMachine.Wpf
try
{
HandleException(e.Exception);
MessageBox.Show("UI线程异常:" + e.Exception.Message);
//MessageBox.Show("UI线程异常:" + e.Exception.Message);
LogService.Error("UI线程异常:" + e.Exception.Message);
}
catch (Exception ex)
{
HandleException(ex);
MessageBox.Show("UI线程发生致命错误");
//MessageBox.Show("UI线程发生致命错误");
LogService.Error("UI线程发生致命错误");
}
finally
{
@@ -374,8 +376,8 @@ namespace CapMachine.Wpf
{
sbEx.Append(e.ExceptionObject);
}
MessageBox.Show(sbEx.ToString());
//MessageBox.Show(sbEx.ToString());
LogService.Error(sbEx.ToString());
}
}
catch (Exception ex)
@@ -402,7 +404,8 @@ namespace CapMachine.Wpf
{
HandleException(exception);
//task线程内未处理捕获
MessageBox.Show("Task线程异常" + e.Exception.Message);
//MessageBox.Show("Task线程异常" + e.Exception.Message);
LogService.Error($"Task线程异常");
}
}
catch (Exception ex)
@@ -423,7 +426,7 @@ namespace CapMachine.Wpf
private void HandleException(Exception ex)
{
//记录日志
LogService.Error(ex.ToString());
LogService.Error($"App捕捉HandleException-{ex.ToString()}");
}