Skip to content

Commit 009ff57

Browse files
authored
Merge pull request #38 from Mijo-Software/mjohne-patch-202502210406
Add files via upload
2 parents 0fe5df8 + f328277 commit 009ff57

File tree

8 files changed

+215
-107
lines changed

8 files changed

+215
-107
lines changed

AboutBoxForm.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ internal partial class AboutBoxForm : Form
1414
/// </summary>
1515
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
1616

17+
/// <summary>
18+
/// Handles exceptions by logging the error and showing a message box.
19+
/// </summary>
20+
/// <param name="ex">The exception that occurred.</param>
21+
/// <param name="message">The message to log and display.</param>
22+
/// <param name="sender">The source of the event that caused the exception.</param>
23+
/// <param name="e">The event data associated with the exception.</param>
24+
private static void HandleException(Exception ex, string message, object? sender = null, EventArgs? e = null)
25+
{
26+
// Implement logging logic here (e.g., log to a file or monitoring system)
27+
string msg = $"Error: {ex}\nMessage: {ex.Message}\nStackTrack: {ex.StackTrace}\nSender: {sender}, EventArgs: {e}";
28+
Debug.WriteLine(value: msg);
29+
Console.WriteLine(value: msg);
30+
Logger.Error(exception: ex, message: msg);
31+
_ = MessageBox.Show(text: message, caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
32+
}
33+
1734
/// <summary>
1835
/// Set a specific text to the status bar
1936
/// </summary>
@@ -110,7 +127,7 @@ private void SetStatusbar_Enter(object sender, EventArgs e)
110127
}
111128
catch (Exception ex)
112129
{
113-
HandleException(ex: ex, message: "An error occurred while setting the status bar text.");
130+
HandleException(ex: ex, message: "An error occurred while setting the status bar text.", sender: sender, e: e);
114131
}
115132
}
116133

@@ -148,21 +165,9 @@ private void AboutBoxForm_KeyDown(object? sender, KeyEventArgs e)
148165
}
149166
catch (Exception ex)
150167
{
151-
HandleException(ex: ex, message: "An error occurred while handling the KeyDown event.");
168+
HandleException(ex: ex, message: "An error occurred while setting the status bar text.", sender: sender, e: e);
152169
}
153170
}
154-
155-
/// <summary>
156-
/// Handles exceptions by logging the error and showing a message box.
157-
/// </summary>
158-
/// <param name="ex">The exception that occurred.</param>
159-
/// <param name="message">The message to log and display.</param>
160-
private static void HandleException(Exception ex, string message)
161-
{
162-
Debug.WriteLine(value: ex);
163-
Logger.Error(exception: ex, message: message);
164-
_ = MessageBox.Show(text: message, caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
165-
}
166171
}
167172
}
168173

DisksizeWatcher.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ApplicationIcon>Resources\Disksize-Watcher_logo.ico</ApplicationIcon>
1212
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1313
<Title>Disksize Watcher</Title>
14-
<Version>0.8.0.14</Version>
14+
<Version>0.8.1.15</Version>
1515
<Authors>Mijo Software</Authors>
1616
<Product>Disksize Watcher</Product>
1717
<Description>Control the disk size</Description>

LicenseForm.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ internal partial class LicenseForm : Form
1313
/// </summary>
1414
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
1515

16+
/// <summary>
17+
/// Handles exceptions by logging the error and showing a message box.
18+
/// </summary>
19+
/// <param name="ex">The exception that occurred.</param>
20+
/// <param name="message">The message to log and display.</param>
21+
/// <param name="sender">The source of the event that caused the exception.</param>
22+
/// <param name="e">The event data associated with the exception.</param>
23+
private static void HandleException(Exception ex, string message, object? sender = null, EventArgs? e = null)
24+
{
25+
// Implement logging logic here (e.g., log to a file or monitoring system)
26+
string msg = $"Error: {ex}\nMessage: {ex.Message}\nStackTrack: {ex.StackTrace}\nSender: {sender}, EventArgs: {e}";
27+
Debug.WriteLine(value: msg);
28+
Console.WriteLine(value: msg);
29+
Logger.Error(exception: ex, message: msg);
30+
_ = MessageBox.Show(text: message, caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
31+
}
32+
1633
/// <summary>
1734
/// Set a specific text to the status bar
1835
/// </summary>
@@ -30,18 +47,6 @@ private void SetStatusbarText(string text)
3047
}
3148
}
3249

33-
/// <summary>
34-
/// Handles exceptions by logging the error and showing a message box.
35-
/// </summary>
36-
/// <param name="ex">The exception that occurred.</param>
37-
/// <param name="message">The message to log and display.</param>
38-
private static void HandleException(Exception ex, string message)
39-
{
40-
Debug.WriteLine(value: ex);
41-
Logger.Error(exception: ex, message: message);
42-
_ = MessageBox.Show(text: message, caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
43-
}
44-
4550
/// <summary>
4651
/// Constructor
4752
/// </summary>
@@ -113,7 +118,7 @@ private void SetStatusbar_Enter(object sender, EventArgs e)
113118
}
114119
catch (Exception ex)
115120
{
116-
HandleException(ex: ex, message: "An error occurred while setting the status bar text.");
121+
HandleException(ex: ex, message: "An error occurred while setting the status bar text.", sender: sender, e: e);
117122
}
118123
}
119124

@@ -151,7 +156,7 @@ private void LicenseForm_KeyDown(object? sender, KeyEventArgs e)
151156
}
152157
catch (Exception ex)
153158
{
154-
HandleException(ex: ex, message: "An error occurred while handling the KeyDown event.");
159+
HandleException(ex: ex, message: "An error occurred while setting the status bar text.", sender: sender, e: e);
155160
}
156161
}
157162
}

0 commit comments

Comments
 (0)