Question

I am trying to catch exception from OnlineIdAuthenticator::AuthenticateUserAsync method, which occurs when there is no internet connection for example.

I've found some info about this topic, but it didn't really help me.

Here is the code which demonstrates the way that I tried to process errors:

auto auth = ref new OnlineIdAuthenticator ();
auto request = ref new OnlineIdServiceTicketRequest ("wl.signin wl.basic wl.skydrive_update", "DELEGATION");
auto request_vec = ref new Vector <OnlineIdServiceTicketRequest ^> ();
request_vec->Append (request);

create_task (auth->AuthenticateUserAsync (request_vec, CredentialPromptType::RetypeCredentials))
.then ([] (UserIdentity ^ident)
{
    try
    {
        auto ticket = ident->Tickets->GetAt (0);
        token = std::wstring (ticket->Value->Data ());
    }
    catch (const concurrency::task_canceled &)
    {
        int _break_point_here = 0;
    }
    catch (const std::exception &)
    {
        int _break_point_here = 0;
    }
    catch (Platform::Exception ^ex)
    {
        int _break_point_here = 0;
    }
});

But no one from these catches doesn't work when AuthenticateUserAsync method fails. Any help, please. What is the right way to catch exceptions from asynchronous method?

Was it helpful?

Solution

I've got answer here. Question is closed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top