win32_exception.hpp 851 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "../exception.hpp"
  3. #include <windows.h>
  4. namespace nkg::exceptions {
  5. class win32_exception final : public ::nkg::exception {
  6. public:
  7. using error_code_t = decltype(GetLastError());
  8. private:
  9. error_code_t m_error_code;
  10. std::string m_error_string;
  11. public:
  12. win32_exception(std::string_view file, int line, error_code_t win32_error_code, std::string_view message) noexcept;
  13. [[nodiscard]]
  14. virtual bool error_code_exists() const noexcept override {
  15. return true;
  16. }
  17. [[nodiscard]]
  18. virtual intptr_t error_code() const noexcept override {
  19. return m_error_code;
  20. }
  21. [[nodiscard]]
  22. virtual const std::string& error_string() const noexcept override {
  23. return m_error_string;
  24. }
  25. };
  26. }