Just confused about why the flow doesn't reach catch block. I do understand that whenever an exception has occured OnError
method will be called, but shouldn't an exception occur when ToObservable
is called? It is only when processing the third number(0), an exception occurs. I am totally confued.
static void Main()
{
try
{
var numbers = from number in
new int[] { 1, 2, 0, 3 }
select 10 / number;
var observable = numbers.ToObservable();
observable.Subscribe(OnNext, OnError, OnComplete);
Console.ReadKey();
}
catch (Exception exc)
{
Console.WriteLine("Program terminated with the following message - {0}", exc.Message);
}
}
private static void OnNext(int i)
{
Console.WriteLine("Output : " + i);
}
private static void OnError(Exception exc)
{
Console.WriteLine("In oops : {0}", exc.Message);
}
private static void OnComplete()
{
Console.WriteLine("In done");
}