exception.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <util/generic/string.h>
  3. #include <exception>
  4. namespace NYT {
  5. ////////////////////////////////////////////////////////////////////////////////
  6. // These are poor man's versions of NYT::TErrorException to be used in
  7. // a limited subset of core libraries that are needed to implement NYT::TError.
  8. class TSimpleException
  9. : public std::exception
  10. {
  11. public:
  12. explicit TSimpleException(TString message);
  13. const TString& GetMessage() const;
  14. const char* what() const noexcept override;
  15. protected:
  16. const TString Message_;
  17. };
  18. class TCompositeException
  19. : public TSimpleException
  20. {
  21. public:
  22. explicit TCompositeException(TString message);
  23. TCompositeException(
  24. const std::exception& exception,
  25. TString message);
  26. const std::exception_ptr& GetInnerException() const;
  27. const char* what() const noexcept override;
  28. private:
  29. const std::exception_ptr InnerException_;
  30. const TString What_;
  31. };
  32. ////////////////////////////////////////////////////////////////////////////////
  33. } // namespace NYT