diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs index 6ead2216e6dd..11b97f2da216 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs @@ -65,7 +65,7 @@ public async Task ProcessFrame(Messages.Frame frame) private async Task ConfigureServer() { var assembly = _rcClient.AppType.Assembly; - if (assembly.GetCustomAttributes(typeof(ProjectConfigurationAttribute), false) is ProjectConfigurationAttribute[] configs) + if (assembly.GetCustomAttributes(typeof(ProjectConfigurationAttribute), false) is ProjectConfigurationAttribute[] { Length: > 0 } configs) { _status.ReportServerState(HotReloadState.Initializing); @@ -85,14 +85,23 @@ private async Task ConfigureServer() _status.ReportInvalidRuntime(); } - ConfigureServer message = new(_projectPath, GetMetadataUpdateCapabilities(), _serverMetadataUpdatesEnabled, config.MSBuildProperties); + var message = new ConfigureServer(_projectPath, GetMetadataUpdateCapabilities(), _serverMetadataUpdatesEnabled, config.MSBuildProperties); await _rcClient.SendMessage(message); + + if (this.Log().IsEnabled(LogLevel.Trace)) + { + this.Log().Trace($"Successfully sent request to configure HR server for project '{_projectPath}'."); + } } - catch + catch (Exception error) { _status.ReportServerState(HotReloadState.Disabled); - throw; + + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError("Unable to configure HR server", error); + } } } else @@ -101,7 +110,7 @@ private async Task ConfigureServer() if (this.Log().IsEnabled(LogLevel.Error)) { - this.Log().LogError("Unable to find ProjectConfigurationAttribute"); + this.Log().LogError("Unable to configure HR server as ProjectConfigurationAttribute is missing."); } } } diff --git a/src/Uno.UI.RemoteControl/RemoteControlClient.cs b/src/Uno.UI.RemoteControl/RemoteControlClient.cs index 5df9baac1e12..e350bab76e40 100644 --- a/src/Uno.UI.RemoteControl/RemoteControlClient.cs +++ b/src/Uno.UI.RemoteControl/RemoteControlClient.cs @@ -499,7 +499,17 @@ private async Task ProcessMessages(WebSocket socket, CancellationToken ct) foreach (var processor in _processors) { - await processor.Value.Initialize(); + try + { + await processor.Value.Initialize(); + } + catch (Exception error) + { + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError($"Failed to initialize processor '{processor}'.", error); + } + } } StartKeepAliveTimer(); @@ -526,14 +536,23 @@ private async Task ProcessMessages(WebSocket socket, CancellationToken ct) this.Log().Trace($"Received frame [{frame.Scope}/{frame.Name}]"); } - bool skipProcessing = false; - + var skipProcessing = false; foreach (var preProcessor in _preprocessors) { - if (await preProcessor.SkipProcessingFrame(frame)) + try + { + if (await preProcessor.SkipProcessingFrame(frame)) + { + skipProcessing = true; + break; + } + } + catch (Exception error) { - skipProcessing = true; - break; + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError($"Error while **PRE**processing frame [{frame.Scope}/{frame.Name}]", error); + } } } @@ -554,9 +573,9 @@ private async Task ProcessMessages(WebSocket socket, CancellationToken ct) } else { - if (this.Log().IsEnabled(LogLevel.Error)) + if (this.Log().IsEnabled(LogLevel.Trace)) { - this.Log().LogError($"Unknown Frame scope {frame.Scope}"); + this.Log().Trace($"Unknown Frame scope {frame.Scope}"); } } }