25 #include "Exception.hpp"
29 #include <system_error>
33 Exception::Exception(std::error_code ev) : m_errorCode{ev} {}
35 Exception::Exception(std::error_code ev,
const std::string &what) :
40 const char *Exception::what() const noexcept
43 m_what = m_errorCode.message();
44 return m_what.c_str();
49 const char *name()
const noexcept
override;
50 std::string message(
int ev)
const override;
53 const char *ErrorCategory::name() const noexcept
55 return "MotionControllerError";
58 std::string ErrorCategory::message(
int ev)
const
63 return ::strerror(ev);
67 case ErrorCode::IncompatibleUnits:
return "Cannot convert units";
68 case ErrorCode::InternalError:
return "Internal error";
69 default:
return "Unknown error";
73 const ErrorCategory errorCategory{};
75 std::error_code make_error_code(
ErrorCode e)
77 return {
static_cast<int>(e), errorCategory};
80 Exception make_errno_exception(std::error_code ev)
82 return Exception(ev, ::strerror(errno));
ErrorCode
Error related to MotionController.
main motion-lib namespace