debug: log crash_log.txt with full stack trace on any unhandled exception or Post failure
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user