diff --git a/src/misc/IniFile.cs b/src/misc/IniFile.cs index b3bb311f..e15e71e1 100644 --- a/src/misc/IniFile.cs +++ b/src/misc/IniFile.cs @@ -1,7 +1,7 @@ // // WinCompose — a compose key for Windows — http://wincompose.info/ // -// Copyright © 2013—2019 Sam Hocevar +// Copyright © 2013—2020 Sam Hocevar // // This program is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -10,6 +10,7 @@ // See http://www.wtfpl.net/ for more details. // +using System; using System.IO; using System.Text; using System.Threading; @@ -27,7 +28,10 @@ public void LoadEntry(SettingsEntry entry, string section, string key) try { if (!m_mutex.WaitOne(2000)) + { + Log.Debug($"Failed to acquire settings lock"); return; + } } catch (AbandonedMutexException) { @@ -65,6 +69,10 @@ public void LoadEntry(SettingsEntry entry, string section, string key) FullPath); } } + catch (Exception ex) + { + Log.Debug($"Failed to load settings: {ex}"); + } finally { // Ensure the mutex is always released even if an @@ -81,7 +89,10 @@ public void SaveEntry(string value, string section, string key) try { if (!m_mutex.WaitOne(2000)) + { + Log.Debug($"Failed to acquire settings lock"); return; + } } catch (AbandonedMutexException) { @@ -96,6 +107,10 @@ public void SaveEntry(string value, string section, string key) if (section != "global") NativeMethods.WritePrivateProfileString("global", key, null, FullPath); } + catch (Exception ex) + { + Log.Debug($"Failed to save settings: {ex}"); + } finally { // Ensure the mutex is always released even if an diff --git a/src/misc/Utils.cs b/src/misc/Utils.cs index 08e732b0..3e0d633e 100644 --- a/src/misc/Utils.cs +++ b/src/misc/Utils.cs @@ -1,7 +1,7 @@ // // WinCompose — a compose key for Windows — http://wincompose.info/ // -// Copyright © 2013—2019 Sam Hocevar +// Copyright © 2013—2020 Sam Hocevar // // This program is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -25,8 +25,9 @@ public static bool EnsureDirectory(string directory) Directory.CreateDirectory(directory); return true; } - catch (Exception) + catch (Exception ex) { + Log.Debug($"Could not create {directory}: {ex}"); return false; } } diff --git a/src/settings/SettingsEntry.cs b/src/settings/SettingsEntry.cs index c69776a3..d4dcb30e 100644 --- a/src/settings/SettingsEntry.cs +++ b/src/settings/SettingsEntry.cs @@ -1,7 +1,7 @@ // // WinCompose — a compose key for Windows — http://wincompose.info/ // -// Copyright © 2013—2019 Sam Hocevar +// Copyright © 2013—2020 Sam Hocevar // 2014—2015 Benjamin Litzelmann // // This program is free software. It comes without any warranty, to @@ -91,8 +91,9 @@ public override void LoadString(string str) ? (T)cv.ConvertFrom(str) : (T)Convert.ChangeType(str, typeof(T)); } - catch (Exception) + catch (Exception ex) { + Log.Debug($"Could not load settings entry {str}: {ex}"); } } }