Caliburn action message swallows exceptions when working with async methods

Topics: Actions & Coroutines
Oct 14, 2013 at 6:36 PM
Edited Oct 14, 2013 at 6:36 PM

I have an async method which throws an exception. I want to handle the exception in the generic unhandled exception handler, but the exception never bubbles up so far. It seems it gets caught somewhere in the ActionMessage.
public async Task BeginProcess()
    throw new Exception("Test");
Can anyone explain me this behavior and how I can get the exceptions to bubble up?

Oct 14, 2013 at 7:33 PM
The behavior for normal methods, coroutines and async (Task based) methods is the same when called from an ActionMessage.
You can use Coroutine.Completed event to get your exception.
Sep 23, 2014 at 5:44 AM
The unhandled exception handler seems to fire if you change the action method to return void rather than Task

public async void BeginProcess()
    throw new Exception("Test");
I was always under the impression that async void was in most cases bad(TM) code, but it appears to be whats required in this case. Not sure why Caliburn doesn't handle both situations similarly.