// 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; }
void CasaLens::handle_error(pplx::task<void>& t) { try { t.get(); } catch(...) { // Ignore the error, Log it if a logger is available } }
void odata_test_service::handle_error(pplx::task<void>& t) { try { t.get(); } catch(...) { // Ignore the error, Log it if a logger is available } }