Skip to content

Commit 6e12307

Browse files
**fix: add bug reporting to exception handlers**
- Integrated `SharedBugReportService` and `ReportBugAsync` calls across ArchiveService, UpdateService, MainWindow, and related error paths. - Updated BugReportService payload to match API model (removed extraneous fields). - Bumped version to 2.6.1.
1 parent a7fd59c commit 6e12307

5 files changed

Lines changed: 39 additions & 11 deletions

File tree

BatchConvertToCHD/BatchConvertToCHD.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<UseWPF>true</UseWPF>
99
<ApplicationIcon>icon\chd.ico</ApplicationIcon>
1010
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
11-
<AssemblyVersion>2.6.0</AssemblyVersion>
12-
<FileVersion>2.6.0</FileVersion>
11+
<AssemblyVersion>2.6.1</AssemblyVersion>
12+
<FileVersion>2.6.1</FileVersion>
1313
<IsPackable>false</IsPackable>
1414
<NeutralLanguage>en</NeutralLanguage>
1515
<DebugType>embedded</DebugType>

BatchConvertToCHD/MainWindow.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ private async Task<bool> ValidateExecutableAccessAsync(string exePath, string ex
321321
{
322322
LogMessage($"ERROR: Cannot access {exeName}. {ex.Message}");
323323
ShowError($"Cannot access {exeName}. Check antivirus or permissions.");
324+
_ = ReportBugAsync($"Cannot access {exeName}", ex);
324325
return false;
325326
}
326327
}
@@ -418,6 +419,7 @@ private async Task<bool> ValidateChdmanCompatibilityAsync(string chdmanPath, Can
418419

419420
// Other errors are acceptable - at least the exe started or we have a generic error
420421
LogMessage($"WARNING: Could not validate chdman compatibility: {ex.Message}");
422+
_ = ReportBugAsync("Could not validate chdman compatibility", ex);
421423
return true;
422424
}
423425
}
@@ -1423,6 +1425,7 @@ private async Task<bool> ProcessSingleFileForConversionAsync(string chdmanPath,
14231425
catch (Exception ex)
14241426
{
14251427
LogMessage($"Direct conversion attempt error for {originalName}: {ex.Message}");
1428+
_ = ReportBugAsync($"Direct conversion attempt error for {originalName}", ex);
14261429
}
14271430

14281431
// Fallback: If direct conversion failed and we haven't already extracted to temp (i.e. it was a direct file attempt),
@@ -1491,6 +1494,7 @@ private async Task<bool> ProcessSingleFileForConversionAsync(string chdmanPath,
14911494
catch (Exception ex)
14921495
{
14931496
LogMessage($"Retry via temp failed for {originalName}: {ex.Message}");
1497+
_ = ReportBugAsync($"Retry via temp failed for {originalName}", ex);
14941498
}
14951499
}
14961500

@@ -1543,6 +1547,7 @@ private async Task<bool> ProcessSingleFileForConversionAsync(string chdmanPath,
15431547
catch (Exception ex)
15441548
{
15451549
LogMessage($"Error processing {originalName}: {ex.Message}");
1550+
_ = ReportBugAsync($"Error processing {originalName}", ex);
15461551
if (!string.IsNullOrEmpty(outputChd)) await TryDeleteFileAsync(outputChd, "failed CHD", CancellationToken.None);
15471552
return false;
15481553
}
@@ -1667,6 +1672,7 @@ private static async Task MoveVerifiedFileAsync(string sourceFile, string target
16671672
{
16681673
// Log error but don't fail the verification
16691674
Debug.WriteLine($"Failed to move file {sourceFile}: {ex.Message}");
1675+
_ = ReportBugAsync($"Failed to move file {sourceFile}", ex);
16701676
}
16711677
}
16721678

@@ -2498,6 +2504,7 @@ private async Task DeleteOriginalGameFilesAsync(string inputFile, CancellationTo
24982504
catch (Exception ex)
24992505
{
25002506
LogMessage($"Delete error: {ex.Message}");
2507+
_ = ReportBugAsync("Delete error", ex);
25012508
}
25022509
}
25032510

BatchConvertToCHD/Services/ArchiveService.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ public ArchiveService(string maxCsoPath, bool isMaxCsoAvailable)
188188
}
189189
catch (Exception ex)
190190
{
191+
// Report bug if service is available
192+
try
193+
{
194+
if (App.SharedBugReportService != null)
195+
{
196+
_ = App.SharedBugReportService.SendBugReportAsync("Error extracting archive", ex);
197+
}
198+
}
199+
catch
200+
{
201+
// Ignore errors in bug reporting to avoid infinite loops
202+
}
203+
191204
return (false, new List<string>(), tempDirectoryRoot, $"Error extracting archive: {ex.Message}");
192205
}
193206
}
@@ -273,6 +286,18 @@ private static void ExtractArchiveWithFallback<TArchive>(
273286
catch (Exception ex)
274287
{
275288
onLog($"Direct extraction failed ({ex.Message}). Attempting fallback with local copy...");
289+
// Report bug if service is available
290+
try
291+
{
292+
if (App.SharedBugReportService != null)
293+
{
294+
_ = App.SharedBugReportService.SendBugReportAsync("Direct extraction failed", ex);
295+
}
296+
}
297+
catch
298+
{
299+
// Ignore errors in bug reporting to avoid infinite loops
300+
}
276301
}
277302

278303
if (directExtractionSuccess)

BatchConvertToCHD/Services/BugReportService.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,22 @@ public async Task<bool> SendBugReportAsync(string message, Exception? ex = null)
6262
// Build the formatted message with all details
6363
var formattedMessage = BuildFormattedReport(message, ex);
6464

65-
// Get environment details
65+
// Get environment details for version field
6666
var envDetails = GetEnvironmentDetails();
6767

6868
// Get exception stack trace
6969
var stackTrace = GetExceptionStackTrace(ex);
7070

7171
// Create the request payload matching the API's BugReportRequest model
72+
// Only include fields defined in BugReportRequest: Message, ApplicationName, Version, UserInfo, Environment, StackTrace
7273
var requestPayload = new
7374
{
7475
message = formattedMessage,
7576
applicationName = _applicationName,
7677
version = envDetails.ApplicationVersion,
7778
userInfo = Environment.UserName,
7879
environment = "Production",
79-
stackTrace,
80-
osVersion = envDetails.OsVersion,
81-
architecture = envDetails.Architecture,
82-
bitness = envDetails.Bitness,
83-
windowsVersion = envDetails.WindowsVersion,
84-
processorCount = envDetails.ProcessorCount,
85-
baseDirectory = envDetails.BaseDirectory,
86-
tempPath = envDetails.TempPath
80+
stackTrace
8781
};
8882

8983
// Create JSON content

BatchConvertToCHD/Services/UpdateService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
116116
catch (Exception urlEx)
117117
{
118118
onLog($"Failed to open browser: {urlEx.Message}");
119+
_ = onBugReport("Failed to open browser", urlEx);
119120

120121
// Copy URL to clipboard
121122
try
@@ -125,6 +126,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
125126
catch (Exception clipboardEx)
126127
{
127128
onLog($"Failed to copy URL to clipboard: {clipboardEx.Message}");
129+
_ = onBugReport("Failed to copy URL to clipboard", clipboardEx);
128130
}
129131

130132
// Show URL in message box so user can manually access it

0 commit comments

Comments
 (0)