Home

JavascriptException error when IAsyncEnumerable/IObservable initial exception

LINQPad v7.4.9, following code:

void Main()
{
    GetIds().Dump();
}

async IAsyncEnumerable<int> GetIds()
{
    throw new Exception("Error");
    for (int i = 0; i < 5; ++i)
    {
        yield return i;
        await Task.Delay(100);
    }
}

Hit F5, will popup following error:

Non-initial exception will be good:

void Main()
{
    GetIds().Dump();
}

async IAsyncEnumerable<int> GetIds()
{   
    for (int i = 0; i < 5; ++i)
    {
        yield return i;
        await Task.Delay(100);

        if (i == 3) throw new Exception("Error");
    }
}

Comments

Sign In or Register to comment.