using System; using System.Diagnostics; namespace JiLinApp.Core.Avalonia; public class RxAppExceptionHandler : IObserver { private static RxAppExceptionHandler? _instance; public static RxAppExceptionHandler Instance { get { return _instance ??= new(); } } public delegate void ExceptionHandler(Exception e); public event ExceptionHandler? OnExceptionHandler; public void OnNext(Exception e) { if (Debugger.IsAttached) Debugger.Break(); OnException(e); } public void OnError(Exception e) { if (Debugger.IsAttached) Debugger.Break(); OnException(e); } public void OnCompleted() { } private void OnException(Exception e) { OnExceptionHandler?.Invoke(e); } }