GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
fix(domain): format error message successfully on unknown user config properties
Lars Berger1e8b13a2381d
diff --git a/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs b/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.csindex ebb6199c..6b29b768 100644--- a/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs+++ b/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs@@ -1,5 +1,4 @@-using GlazeWM.Domain.UserConfigs.Commands;-using GlazeWM.Domain.Workspaces.Commands;+using GlazeWM.Domain.UserConfigs.Commands;using GlazeWM.Infrastructure.Bussing;using GlazeWM.Infrastructure.WindowsApi;using GlazeWM.Infrastructure.Yaml;@@ -98,17 +97,12 @@ namespace GlazeWM.Domain.UserConfigs.CommandHandlers{var errorMessage = exception.Message;- if (exception.InnerException?.Message != null)- {- var unknownPropertyRegex = new Regex(@"Property '(?<property>.*?)' not found on type");- var match = unknownPropertyRegex.Match(exception.InnerException.Message);-- // Improve error message shown in case of unknown property error.- if (match.Success)- errorMessage = $"Unknown property in config: {match.Groups["property"]}.";- else- errorMessage += $". {exception.InnerException.Message}";- }+ var unknownPropertyRegex = new Regex(@"Could not find member '(?<property>.*?)' on object");+ var unknownPropertyMatch = unknownPropertyRegex.Match(errorMessage);++ // Improve error message shown in case of unknown property error.+ if (unknownPropertyMatch.Success)+ return $"Unknown property in config: '{unknownPropertyMatch.Groups["property"]}'.";return errorMessage;}