ExceptionKeystone.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <keystone/keystone.h>
  3. #include "Exception.hpp"
  4. namespace ARL {
  5. class KeystoneError final : public Exception {
  6. private:
  7. ks_err m_ErrorCode;
  8. public:
  9. template<typename... __ArgTypes>
  10. KeystoneError(const char* SourceFile, size_t SourceLine, ks_err ErrorCode, const char* Format, __ArgTypes&&... Args) noexcept :
  11. Exception(SourceFile, SourceLine, Format, std::forward<__ArgTypes>(Args)...),
  12. m_ErrorCode(ErrorCode) {}
  13. [[nodiscard]]
  14. // NOLINTNEXTLINE: mark "virtual" explicitly for more readability
  15. virtual bool HasErrorCode() const noexcept override {
  16. return true;
  17. }
  18. [[nodiscard]]
  19. // NOLINTNEXTLINE: mark "virtual" explicitly for more readability
  20. virtual intptr_t ErrorCode() const noexcept override {
  21. return m_ErrorCode;
  22. }
  23. [[nodiscard]]
  24. // NOLINTNEXTLINE: mark "virtual" explicitly for more readability
  25. virtual const char* ErrorString() const noexcept override {
  26. return ks_strerror(m_ErrorCode);
  27. }
  28. };
  29. }