Skip to content

Task to AsyncResult transition wraps Exception into the AggregateExceptionΒ #154

@xperiandri

Description

@xperiandri

Describe the bug

    member this.AsyncAcquireTokenInteractively (uiThread, correlationId) = asyncResult {
        do! Async.SwitchToContext uiThread
        let builder =
            pca.AcquireTokenInteractive(options.Scopes)
                .WithCorrelationId(correlationId)
        if not (isNull configureInteractive) then configureInteractive.Invoke(builder)
        try return! builder.ExecuteAsync() // FSharp.Control.FusionTasks is used not to write |> Async.AwaitTask
        with :? MsalClientException as ex -> return! Error ex.ErrorCode
    }

Matching by the MsalClientException does not happen as it is wrapped by the AggregateException.

To Reproduce
Steps to reproduce the behavior:

  1. Call Task returning method via return! in an asyncResult CE
  2. Catch exception
  3. You will see that it is always the AggregateException.

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • Version 2.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions