title: ReactiveUI exception handling
body: <p>I've looked around at a number of the ReactiveUI samples, but I can't see a good simple example of how to handle exceptions, where a message should be displayed to the user. (If there is a good example can somebody point me to it?).</p>
  
  <p>My first question is how to handle an exception with ReactiveCommand and ToProperty. For example, I have the following code:</p>
  
  <pre><code>public class MainWindowViewModel : ReactiveObject
  {
      public ReactiveCommand CalculateTheAnswer { get; set; }
  
      public MainWindowViewModel()
      {
          CalculateTheAnswer = new ReactiveCommand();
  
          CalculateTheAnswer
              .SelectMany(_ =&gt; AnswerCalculator())
              .ToProperty(this, x =&gt; x.TheAnswer);
  
          CalculateTheAnswer.ThrownExceptions
              .Select(exception =&gt; MessageBox.Show(exception.Message));
      }
  
      private readonly ObservableAsPropertyHelper&lt;int&gt; _theAnswer;
      public int TheAnswer
      {
          get { return _theAnswer.Value; }
      }
  
      private static IObservable&lt;int&gt; AnswerCalculator()
      {
          var task = Task.Factory.StartNew(() =&gt;
          {
              throw new ApplicationException("Unable to calculate answer, because I don't know what the question is");
              return 42;
          });
  
          return task.ToObservable();
      }
  }
  </code></pre>
  
  <p>I think I must be misunderstanding ThrownExceptions, because this observable is not receiving any items when I run the code above. What am I doing wrong?</p>
  
  <p>My second question is how would I do this in a MVVM-friendly way. <a href="http://blog.paulbetts.org/index.php/2012/04/23/announcing-reactiveui-3-1/" rel="noreferrer">This blog entry</a> mentions a <strong>User Errors</strong> feature, but I can't find any documentation on how to use it. How would I implement it into the above example?</p>
  
  <p><strong>Edit</strong>: I've published an example solution <a href="https://github.com/wmaurer/ReactiveUI-Examples/tree/master/ReactiveUI-UserError" rel="noreferrer">on github</a> based on Paul's answer below.</p>