예제 #1
1
// In case of any failure to fetch data from a service,
// create a json object with "error" key and value containing the exception details.
pplx::task<json::value> CasaLens::handle_exception(pplx::task<json::value>& t, const utility::string_t& field_name)
{
    try
    {
        t.get();
    }
    catch (const std::exception& ex)
    {
        json::value error_json = json::value::object();
        error_json[field_name] = json::value::object();
        error_json[field_name][error_json_key] = json::value::string(utility::conversions::to_string_t(ex.what()));
        return pplx::task_from_result<json::value>(error_json);
    }

    return t;
}
예제 #2
0
void CasaLens::handle_error(pplx::task<void>& t)
{  
    try
    {
        t.get();
    }
    catch(...)
    {
        // Ignore the error, Log it if a logger is available 
    }
}
예제 #3
0
 void odata_test_service::handle_error(pplx::task<void>& t)
 {  
     try
     {
         t.get();
     }
     catch(...)
     {
         // Ignore the error, Log it if a logger is available 
     }
 }
void HandleJson::HandleError(pplx::task<T>& t)
{
    try
    {
        t.wait();
    }
    catch (const web::http::http_exception& ex)
    {
        std::cout << "Http Exception Occurred: " << ex.what() << std::endl;
    }
    catch (const std::exception& e)
    {
        std::cout << "Exception Occurred" << e.what() << std::endl;
    }
}