diff --git a/winui/App.xaml.cs b/winui/App.xaml.cs index 647b95b9..d3ef0a41 100644 --- a/winui/App.xaml.cs +++ b/winui/App.xaml.cs @@ -21,7 +21,11 @@ public partial class App : Application _laufend = this; // Ein Absturz hinterlaesst seinen Grund in %APPDATA%\Pokerfreakbsturz.txt (sonst sieht man nur // "Microsoft.UI.Xaml.dll" im Ereignisprotokoll). - UnhandledException += (_, e) => Seiten.Merker.Absturz(e.Exception); + // 30.11.: Ein Fehler in der Oberflaeche beendet das Cockpit nicht mehr (Handled). Das Cockpit traegt den + // Laeufer (Job KILL_ON_JOB_CLOSE): am 30.11. 10:10 riss ein Klick-Fehler (0x800F1000) den Echtgeld-Laeufer mit. + UnhandledException += (_, e) => { Seiten.Merker.Absturz(e.Exception, behandelt: true); e.Handled = true; }; + AppDomain.CurrentDomain.UnhandledException += (_, e) => { if (e.ExceptionObject is Exception x) Seiten.Merker.Absturz(x); }; + TaskScheduler.UnobservedTaskException += (_, e) => { Seiten.Merker.Absturz(e.Exception, behandelt: true); e.SetObserved(); }; } protected override void OnLaunched(LaunchActivatedEventArgs args) diff --git a/winui/Seiten/Bausteine.cs b/winui/Seiten/Bausteine.cs index 4f6437f4..ce73ba10 100644 --- a/winui/Seiten/Bausteine.cs +++ b/winui/Seiten/Bausteine.cs @@ -26,14 +26,15 @@ public static class Merker return null; } - /// Den Grund eines Absturzes neben die Merkdatei schreiben (absturz.txt). - public static void Absturz(Exception e) + /// Den Grund eines Fehlers neben die Merkdatei haengen (absturz.txt; nie ueberschreiben, ab 1 MB als .alt beiseite). + public static void Absturz(Exception e, bool behandelt = false) { try { var pfad = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Datei)!, "absturz.txt"); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(pfad)!); - File.WriteAllText(pfad, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\n{e}\n"); + if (File.Exists(pfad) && new FileInfo(pfad).Length > 1_000_000) File.Move(pfad, pfad + ".alt", true); + File.AppendAllText(pfad, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}{(behandelt ? " (abgefangen, Cockpit laeuft weiter)" : "")}\n{e}\n\n"); } catch { } } diff --git a/winui/Seiten/Ui.cs b/winui/Seiten/Ui.cs index f2b77d6a..b92b1528 100644 --- a/winui/Seiten/Ui.cs +++ b/winui/Seiten/Ui.cs @@ -303,7 +303,7 @@ public sealed class Tippflaeche : Grid PointerReleased += (_, _) => { _schleier.Background = _an ? Ui.Weiss(0.05) : null; Scale = new System.Numerics.Vector3(1); }; Loaded += (_, _) => CenterPoint = new System.Numerics.Vector3((float)ActualWidth / 2, (float)ActualHeight / 2, 0); SizeChanged += (_, _) => CenterPoint = new System.Numerics.Vector3((float)ActualWidth / 2, (float)ActualHeight / 2, 0); - Tapped += (_, e) => { if (_an) { e.Handled = true; Getippt?.Invoke(); } }; + Tapped += (_, e) => { if (_an) { e.Handled = true; try { Getippt?.Invoke(); } catch (Exception x) { Merker.Absturz(x, behandelt: true); } } }; } public bool An