4

I recently upgraded to ReactiveUI 9.3.5, the documentation suggests to handle errors globally via RxApp.DefaultExceptionHandler:

// set at startup
RxApp.DefaultExceptionHandler = new GlobalErrorHandler();

public class GlobalErrorHandler : IObserver<Exception>
{
    public void OnNext(Exception error)
    {
        Debug.Write("An error occurred");
    }

    public void OnError(Exception error) { }

    public void OnCompleted() { }
}

When a command throws an exception, then the global error handler is called as expected.

The problem is that the app will afterwards still crash with an unhandled exception:

  // this crashes the app
  var command = ReactiveCommand.CreateFromTask(async () =>
        {
            throw new Exception();
        })
        .Execute()
        .Subscribe(x =>
        {                
            Debugger.Break();
        });

Is this the expected behaviour and what is the way to catch and handle exceptions in reactive code globally?

Previously I used UserError to throw and handle errors globally, but that's been depreceated.

thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110

0 Answers0