From 1533945126567e8a6717a2ef4e10045c946bc373 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 16 Apr 2026 11:35:47 +0100 Subject: [PATCH] debug: log crash_log.txt with full stack trace on any unhandled exception or Post failure --- EbayListingTool/App.xaml.cs | 2 +- EbayListingTool/Views/NewListingView.xaml.cs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/EbayListingTool/App.xaml.cs b/EbayListingTool/App.xaml.cs index 278bd37..a6c0b71 100644 --- a/EbayListingTool/App.xaml.cs +++ b/EbayListingTool/App.xaml.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; using Microsoft.Extensions.Configuration; diff --git a/EbayListingTool/Views/NewListingView.xaml.cs b/EbayListingTool/Views/NewListingView.xaml.cs index 3baa963..7e88e4e 100644 --- a/EbayListingTool/Views/NewListingView.xaml.cs +++ b/EbayListingTool/Views/NewListingView.xaml.cs @@ -671,7 +671,22 @@ public partial class NewListingView : UserControl SetState(ListingState.Success); GetWindow()?.SetStatus($"Listed: {_draft.Title}"); } - catch (Exception ex) { ShowError("Post Failed", ex.Message); } + catch (Exception ex) + { + // Log full stack trace to help diagnose crashes + try + { + var logPath = System.IO.Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "EbayListingTool", "crash_log.txt"); + var msg = $"{DateTime.Now:HH:mm:ss} [Post_Click] {ex.GetType().Name}: {ex.Message}\n{ex.StackTrace}\n"; + if (ex.InnerException != null) + msg += $" Inner: {ex.InnerException.GetType().Name}: {ex.InnerException.Message}\n"; + System.IO.File.AppendAllText(logPath, msg + "\n"); + } + catch { } + ShowError("Post Failed", ex.Message); + } finally { SetPostBusy(false); } }