-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.cs
More file actions
41 lines (35 loc) · 1.26 KB
/
Copy pathHelper.cs
File metadata and controls
41 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.IO;
using System.Text.Json;
using System.Windows;
namespace WinFolderLock
{
public enum WindowMode
{
LockFolder,
UnlockFolder,
PermanentlyUnlockFolder
}
internal static class Helper
{
public static void ExceptionHandler(Exception ex)
{
LogError(ex);
string message = ex switch
{
ArgumentException or IOException or UnauthorizedAccessException or JsonException or NotSupportedException or InvalidOperationException => ex.Message,
_ => $"An unexpected error occurred.\n\nError: {ex.Message}"
};
if (ex.InnerException is not null)
{
message += $"\n\nDetails: {ex.GetBaseException().Message}";
}
_ = MessageBox.Show(message, "WinFolderLock Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
public static void LogError(Exception ex)
{
// Placeholder for error logging. In a production application, this could be
// implemented to write to a log file, event viewer, or centralized logging service.
// Currently, errors are silently caught in the application for non-critical operations.
}
}
}