Exception.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "TString.hpp"
  3. #include <vector>
  4. class Exception {
  5. private:
  6. static inline TString EmptyErrorStr;
  7. TString _File;
  8. size_t _Line;
  9. TString _Message;
  10. std::vector<TString> _Hints;
  11. public:
  12. template<typename... __Ts>
  13. Exception(const TString& FileName,
  14. size_t LineNumber,
  15. const TString& CustomMsg,
  16. __Ts&&... SomeHints) noexcept :
  17. _File(FileName),
  18. _Line(LineNumber),
  19. _Message(CustomMsg),
  20. _Hints{ std::forward<__Ts>(SomeHints)... } {}
  21. const TString& File() const noexcept {
  22. return _File;
  23. }
  24. size_t Line() const noexcept {
  25. return _Line;
  26. }
  27. const TString& Message() const noexcept {
  28. return _Message;
  29. }
  30. std::vector<TString>& Hints() noexcept {
  31. return _Hints;
  32. }
  33. const std::vector<TString>& Hints() const noexcept {
  34. return _Hints;
  35. }
  36. virtual bool HasErrorCode() const noexcept {
  37. return false;
  38. }
  39. virtual uintptr_t ErrorCode() const noexcept {
  40. return 0;
  41. }
  42. virtual const TString& ErrorString() const noexcept {
  43. return EmptyErrorStr;
  44. }
  45. virtual ~Exception() = default;
  46. };