openssl_exception.hpp 861 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include "../exception.hpp"
  3. #include <openssl/err.h>
  4. namespace nkg::exceptions {
  5. class openssl_exception final : public ::nkg::exception {
  6. public:
  7. using error_code_t = decltype(ERR_get_error());
  8. private:
  9. error_code_t m_error_code;
  10. std::string m_error_string;
  11. public:
  12. openssl_exception(std::string_view file, int line, error_code_t openssl_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. }