fajiao
2 years ago
3 changed files with 82 additions and 3 deletions
@ -0,0 +1,42 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
|
|||
namespace JiLinApp.Core.Avalonia; |
|||
|
|||
public class RxAppExceptionHandler : IObserver<Exception> |
|||
{ |
|||
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); |
|||
} |
|||
} |
Loading…
Reference in new issue