Skip to content

AsyncInterceptor cannot handle exeptions #52

Description

@ladenedge

AsyncInterceptor is awesome, but it cannot handle faulted tasks.

On first glance it looks like one could override AfterInvoke(IInvocation invocation, Task task) and check the IsFaulted property of the task, but the last ContinueWith() contains this code:

invocationClone.ReturnValue = t.Result;
this.AfterInvoke(invocationClone);
this.AfterInvoke(invocationClone, t);
return (TResult)invocationClone.ReturnValue;

Thus, AfterInvoke() is only called if task.Result does not throw—which it will if the task is faulted!

What I believe is needed is a check of t.IsFaulted before accessing t.Result and then calling the virtual methods appropriately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions