Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Task that is wrapped as IResult just quietly dies on exception #862

Open
AndersMalmgren opened this issue Jun 22, 2023 · 1 comment

Comments

@AndersMalmgren
Copy link

Thansk to this code in TaskResult class the Coroutine just queitly dies when exception occours in Task.

        protected virtual void OnCompleted(Task task)
        {
            Completed(this, new ResultCompletionEventArgs { WasCancelled = task.IsCanceled, Error = task.Exception });
        }

OnUnhandledException in bootstrapper isnt called either

@darxis
Copy link
Contributor

darxis commented Oct 16, 2024

A workaround to catch unhandled exceptions is to use the Coroutine.Completed event.

public abstract class TypedBootstrapper : BootstrapperBase
{
    protected override void Configure()
    {
        Coroutine.Completed += CoroutineOnCompleted;
    }

    private static void CoroutineOnCompleted(object sender, ResultCompletionEventArgs e)
    {
        if (e.Error != null)
        {
            // Do something with the unhandled exception
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants