edit-icon download-icon

Handle errors

Last Updated: Feb 27, 2018

Error object

Alibaba Cloud C++ SDK does not support exceptions, but you can still use exceptions to handle errors in codes. Each client API returns a result object containing the result and the error object.

  1. auto outcome = client.describeInstances(request);
  2. if (!outcome.isSuccess())
  3. {
  4. Error e = outcome.error();
  5. std::cout << "host: " << e.host() << std::endl;
  6. std::cout << "requestId: " << e.requestId() << std::endl;
  7. std::cout << "errorCode: " << e.errorCode() << std::endl;
  8. std::cout << "errorMessage: " << e.errorMessage() << std::endl;
  9. }

For more information, see Troubleshoot.

Thank you! We've received your feedback.