exceptions.h 867 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <util/generic/yexception.h>
  3. namespace NYql {
  4. // This exception can separate code line and file name from the error message
  5. struct TCodeLineException: public yexception {
  6. TSourceLocation SourceLocation;
  7. mutable TString Message;
  8. ui32 Code;
  9. TCodeLineException(ui32 code);
  10. TCodeLineException(const TSourceLocation& sl, const TCodeLineException& t);
  11. virtual const char* what() const noexcept override;
  12. const char* GetRawMessage() const;
  13. };
  14. TCodeLineException operator+(const TSourceLocation& sl, TCodeLineException&& t);
  15. #define YQL_ENSURE_CODELINE(CONDITION, CODE, ...) \
  16. do { \
  17. if (Y_UNLIKELY(!(CONDITION))) { \
  18. ythrow TCodeLineException(CODE) << __VA_ARGS__; \
  19. } \
  20. } while (0)
  21. } // namespace NYql