ErrorSimulator.hpp 477 B

1234567891011121314151617181920212223242526
  1. #ifndef CORE_ERROR_SIMULATOR_HPP
  2. #define CORE_ERROR_SIMULATOR_HPP
  3. #include <stdexcept>
  4. #ifdef ERROR_SIMULATOR
  5. extern int failStep;
  6. extern int failStepThrow;
  7. #define FAIL_STEP (--failStep == 0)
  8. inline void debugThrow() {
  9. if(--failStepThrow == 0) {
  10. throw std::runtime_error("not a real error");
  11. }
  12. }
  13. #define FAIL_STEP_THROW() debugThrow()
  14. #else
  15. #define FAIL_STEP false
  16. #define FAIL_STEP_THROW() \
  17. do { \
  18. } while(false)
  19. #endif
  20. #endif