Advertisement
whillothewhisp

Houdini Ensure Success

May 26th, 2025 (edited)
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. static std::string get_last_error()
  2. {
  3.     int buffer_length;
  4.     HAPI_GetStatusStringBufLength(
  5.         nullptr, HAPI_STATUS_CALL_RESULT, HAPI_STATUSVERBOSITY_ERRORS, &buffer_length);
  6.     char* buf = new char[buffer_length];
  7.     HAPI_GetStatusString(nullptr, HAPI_STATUS_CALL_RESULT, buf, buffer_length);
  8.     std::string result(buf);
  9.     delete[] buf;
  10.     return result;
  11. }
  12.  
  13. #define ENSURE_SUCCESS( result ) \
  14.     if ( (result) != HAPI_RESULT_SUCCESS ) \
  15.     { \
  16.         std::cout << "failure at " << __FILE__ << ":" << __LINE__ << std::endl; \
  17.         std::cout << get_last_error() << std::endl; \
  18.         exit( 1 ); \
  19.     }
  20.  
  21. get_last_cook_error()
  22. {
  23.     int buffer_length;
  24.     HAPI_GetStatusStringBufLength(
  25.         nullptr,
  26.         HAPI_STATUS_COOK_RESULT, HAPI_STATUSVERBOSITY_ERRORS, &buffer_length);
  27.     char* buf = new char[buffer_length];
  28.     HAPI_GetStatusString(
  29.         nullptr, HAPI_STATUS_CALL_RESULT, buf, buffer_length);
  30.     std::string result(buf);
  31.     delete[] buf;
  32.     return result;
  33. }
  34.  
  35. #define ENSURE_COOK_SUCCESS( result ) \
  36. if ( (result) != HAPI_STATE_READY ) \
  37. { \
  38.     std::cout << "failure at " << __FILE__ << ":" << __LINE__ << std::endl; \
  39.     std::cout << get_last_cook_error() << std::endl; \
  40.     exit( 1 ); \
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement