GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — BmsLightBridge/App.xaml.cs at main · RedMeKool/BmsLightBridge Expand file tree/ Copy pathApp.xaml.csMore file actions 69 lines (60 loc) · 2.71 KB / Copy pathApp.xaml.csFile metadata and controls69 lines (60 loc) · 2.71 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 using System.Windows; namespace BmsLightBridge { public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Catch unhandled exceptions from UI thread DispatcherUnhandledException += (_, args) => { LogException("DispatcherUnhandledException", args.Exception); args.Handled = true; MessageBox.Show( $"An unexpected error occurred:\n\n{args.Exception.Message}\n\nSee BmsLightBridge_errors.log for details.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); }; // Catch unhandled exceptions from background threads System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (_, args) => { LogException("UnobservedTaskException", args.Exception); args.SetObserved(); }; AppDomain.CurrentDomain.UnhandledException += (_, args) => { if (args.ExceptionObject is Exception ex) LogException("UnhandledException", ex); }; } public static void LogException(string source, Exception ex) { try { string logPath = System.IO.Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "BmsLightBridge_errors.log"); string entry = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{source}]\n" + $"{ex.GetType().FullName}: {ex.Message}\n" + $"{ex.StackTrace}\n" + (ex.InnerException != null ? $"--- Inner: {ex.InnerException.GetType().FullName}: {ex.InnerException.Message}\n{ex.InnerException.StackTrace}\n" : "") + new string('-', 80) + "\n"; System.IO.File.AppendAllText(logPath, entry); } catch { /* logging must never crash the app */ } } /// <summary>Appends a plain diagnostic line to BmsLightBridge_errors.log (for non-exception events).</summary> public static void LogMessage(string source, string message) { try { string logPath = System.IO.Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "BmsLightBridge_errors.log"); string entry = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{source}] {message}\n"; System.IO.File.AppendAllText(logPath, entry); } catch { /* logging must never crash the app */ } } } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |