ExceptionCapstone.hpp 883 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include "Exception.hpp"
  3. #include <capstone/capstone.h>
  4. class CapstoneException : public Exception {
  5. private:
  6. cs_err _ErrorCode;
  7. TString _ErrorString;
  8. public:
  9. template<typename... __Ts>
  10. CapstoneException(const TString& FileName,
  11. size_t LineNumber,
  12. cs_err ErrCode,
  13. const TString& CustomMsg, __Ts&&... SomeHints) noexcept :
  14. Exception(FileName, LineNumber, CustomMsg, std::forward<__Ts>(SomeHints)...),
  15. _ErrorCode(ErrCode),
  16. _ErrorString(TStringBuilder(cs_strerror(ErrCode))) {}
  17. virtual bool HasErrorCode() const noexcept override {
  18. return true;
  19. }
  20. virtual uintptr_t ErrorCode() const noexcept override {
  21. return _ErrorCode;
  22. }
  23. virtual const TString& ErrorString() const noexcept override {
  24. return _ErrorString;
  25. }
  26. };