Skip to content

Commit

Permalink
Add debug messages for several silently caught exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
samhocevar committed Nov 27, 2020
1 parent 6d4ff9d commit 3776e17
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
17 changes: 16 additions & 1 deletion src/misc/IniFile.cs
@@ -1,7 +1,7 @@
//
// WinCompose — a compose key for Windows — http://wincompose.info/
//
// Copyright © 2013—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2013—2020 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
Expand All @@ -10,6 +10,7 @@
// See http://www.wtfpl.net/ for more details.
//

using System;
using System.IO;
using System.Text;
using System.Threading;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
Expand All @@ -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)
{
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/misc/Utils.cs
@@ -1,7 +1,7 @@
//
// WinCompose — a compose key for Windows — http://wincompose.info/
//
// Copyright © 2013—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2013—2020 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
Expand All @@ -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;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/settings/SettingsEntry.cs
@@ -1,7 +1,7 @@
//
// WinCompose — a compose key for Windows — http://wincompose.info/
//
// Copyright © 2013—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2013—2020 Sam Hocevar <sam@hocevar.net>
// 2014—2015 Benjamin Litzelmann
//
// This program is free software. It comes without any warranty, to
Expand Down Expand Up @@ -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}");
}
}
}
Expand Down

0 comments on commit 3776e17

Please sign in to comment.