Skip to content

EvaluateAsync execution for Action doesnt throw internal exception #231

Open
@ivan-luxoft

Description

@ivan-luxoft

Implementations ContextEvaluatorExtensions.EvaluateAsync for async Action uses the next method:

public static Task EvaluateAsync<TBLLContext, TDTOMappingService>(this IContextEvaluator<TBLLContext, TDTOMappingService> contextEvaluator, DBSessionMode sessionMode, string customPrincipalName, Func<EvaluatedData<TBLLContext, TDTOMappingService>, Task> action)
    {
        return contextEvaluator.EvaluateAsync(sessionMode, customPrincipalName, evaluatedData => action(evaluatedData).ContinueWith(_ => default(object)));
    }

that hides internal exception, ASP will not handle the next Exception:

[HttpGet]
    public async Task GetException(
        [FromServices] IContextEvaluator<ICPortalBLLContext> contextEvaluator,
        CancellationToken cancellationToken)
    {
        await contextEvaluator.EvaluateAsync(
            DBSessionMode.Write,
            async c =>
            {
                await Task.Delay(200);
                throw new Exception();
            });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions