ExceptionSystem.hpp 1.1 KB

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