ExceptionCapstone.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <capstone/capstone.h>
  3. #include "Exception.hpp"
  4. namespace ARL {
  5. class CapstoneError final : public Exception {
  6. private:
  7. cs_err m_ErrorCode;
  8. public:
  9. template<typename... __ArgTypes>
  10. CapstoneError(const char* SourceFile, size_t SourceLine, cs_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 cs_strerror(m_ErrorCode);
  27. }
  28. };
  29. }