pplx Exception

Jan 15, 2014 at 10:02 AM
I have some problem with below message.
This message appeared when i tried to send many request about 300 times.

~_ExceptionHolder()
    {
        if (_M_exceptionObserved == 0)
        {
            // If you are trapped here, it means an exception thrown in task chain didn't get handled.
            // Please add task-based continuation to handle all exceptions coming from tasks.
            // this->_M_stackTrace keeps the creation callstack of the task generates this exception.
            _REPORT_PPLTASK_UNOBSERVED_EXCEPTION();   <<<<- call stack stop
        }
    }
And call stack is
H2Viewer.exe!pplx::details::_ExceptionHolder::~_ExceptionHolder() 931
H2Viewer.exe!pplx::details::_ExceptionHolder::scalar deleting destructor'(unsigned int)
H2Viewer.exe!std::_Ref_count_obj<pplx::details::_ExceptionHolder>::_Destroy() 885 H2Viewer.exe!std::_Ref_count_base::_Decref() 120
H2Viewer.exe!std::_Ptr_base<pplx::details::_ExceptionHolder>::_Decref() 347 H2Viewer.exe!std::shared_ptr<pplx::details::_ExceptionHolder>::~shared_ptr<pplx::details::_ExceptionHolder>() 624
H2Viewer.exe!pplx::details::_Task_impl_base::~_Task_impl_base() 1697
H2Viewer.exe!pplx::details::_Task_impl<unsigned char>::~_Task_impl<unsigned char>() 2387
H2Viewer.exe!pplx::details::_Task_impl<unsigned char>::
scalar deleting destructor'(unsigned int)
H2Viewer.exe!std::_Ref_count_obj<pplx::details::_Task_impl<unsigned char> >::_Destroy() 884
H2Viewer.exe!std::_Ref_count_base::_Decref() 120
H2Viewer.exe!std::_Ptr_base<pplx::details::_Task_impl<unsigned char> >::_Decref() 347
H2Viewer.exe!std::shared_ptr<pplx::details::_Task_impl<unsigned char> >::~shared_ptr<pplx::details::_Task_impl<unsigned char> >() 624
H2Viewer.exe!pplx::details::_PPLTaskHandle<unsigned char,pplx::task<std::vector<unsigned char,std::allocator<unsigned char> > >::_ContinuationTaskHandle<std::vector<unsigned char,std::allocator<unsigned char> >,void,<lambda_bb02b3f8e611285d839efd2f7bdc8b0e>,std::integral_constant<bool,1>,pplx::details::_TypeSelectorNoAsync>,pplx::details::_ContinuationTaskHandleBase>::~_PPLTaskHandle<unsigned char,pplx::task<std::vector<unsigned char,std::allocator<unsigned char> > >::_ContinuationTaskHandle<std::vector<unsigned char,std::allocator<unsigned char> >,void,<lambda_bb02b3f8e611285d839efd2f7bdc8b0e>,std::integral_constant<bool,1>,pplx::details::_TypeSelectorNoAsync>,pplx::details::_ContinuationTaskHandleBase>() 1605
H2Viewer.exe!pplx::task<std::vector<unsigned char,std::allocator<unsigned char> > >::_ContinuationTaskHandle<std::vector<unsigned char,std::allocator<unsigned char> >,void,<lambda_bb02b3f8e611285d839efd2f7bdc8b0e>,std::integral_constant<bool,1>,pplx::details::_TypeSelectorNoAsync>::~_ContinuationTaskHandle<std::vector<unsigned char,std::allocator<unsigned char> >,void,<lambda_bb02b3f8e611285d839efd2f7bdc8b0e>,std::integral_constant<bool,1>,pplx::details::_TypeSelectorNoAsync>() 3780
H2Viewer.exe!pplx::task<std::vector<unsigned char,std::allocator<unsigned char> > >::_ContinuationTaskHandle<std::vector<unsigned char,std::allocator<unsigned char> >,void,<lambda_bb02b3f8e611285d839efd2f7bdc8b0e>,std::integral_constant<bool,1>,pplx::details::_TypeSelectorNoAsync>::`scalar deleting destructor'(unsigned int)
H2Viewer.exe!pplx::details::_AutoDeleter<pplx::details::_TaskProcHandle>::~_AutoDeleter<pplx::details::_TaskProcHandle>() 108
H2Viewer.exe!pplx::details::_TaskProcHandle::_RunChoreBridge(void * _Parameter) 126
cpprest110d_1_4.dll!pplx::details::_Scheduler_Param::DefaultWorkCallback(struct _TP_CALLBACK_INSTANCE *,void *,struct _TP_WORK *)

I wish you to tell me what to do.
thank you.
Jan 15, 2014 at 5:52 PM
Hi kisuya,

What is happening is you have an exception from a task going unobserved so it is being throw out of the destructor of the last task handle. This means you have an operation in your program with a task that doesn't have a call to wait(), get(), or a task-based continuation. From what you describe in sounds like you are using our http_client. Without seeing your code I'm guessing that right now you have a value-based continuation, which will not be executed if the parent task results in an exception. Your code probably looks something like this:
http_client client(...);
client.request(...).then([](http_response response)
{
    // If an exception occurs from the task this continuation won't execute since there 
    // isn't a value to call this function with.
});
Instead try using a task-based continuation and add some logic to handle any exception that might occur. Our http library throws an exception of type http_exception that contains more information about the cause. It contains a std::error_code.
http_client client(...);
client.request(...).then([](task<http_response> responseTask)
{
    try
    {
        // Get the response out of the response task.
        // This will throw an exception if an error occurred, for example if the connection was lost.
        http_response response = responseTask.get();
    } catch(const http_exception &e)
    {
        // inspect message and error code here and handle error
    }
});
Once you can see the exception you should be able to see more information as to why sometimes a request is failing. Let us know if this helps or you are still stuck.

Thanks,
Steve
Jan 16, 2014 at 1:20 AM
Wow.
You're right!

I've been using value-based continuation.
I understood that using a task-based continuation in this time.

Thanks Steve.