github.com/ledgerwatch/erigon-lib@v1.0.0/pedersen_hash/error_handling.h (about)

     1  #ifndef STARKWARE_UTILS_ERROR_HANDLING_H_
     2  #define STARKWARE_UTILS_ERROR_HANDLING_H_
     3  
     4  #include <exception>
     5  #include <string>
     6  #include <utility>
     7  
     8  namespace starkware {
     9  
    10  class StarkwareException : public std::exception {
    11   public:
    12    explicit StarkwareException(std::string message) : message_(std::move(message)) {}
    13    const char* what() const noexcept { return message_.c_str(); }  // NOLINT
    14  
    15   private:
    16    std::string message_;
    17  };
    18  
    19  /*
    20    We use "do {} while(false);" pattern to force the user to use ; after the macro.
    21  */
    22  #define ASSERT(cond, msg)            \
    23    do {                               \
    24      if (!(cond)) {                   \
    25        throw StarkwareException(msg); \
    26      }                                \
    27    } while (false)
    28  
    29  }  // namespace starkware
    30  
    31  #endif  // STARKWARE_UTILS_ERROR_HANDLING_H_