From e97d9eb1751623e5434aac08a5746350be2a7341 Mon Sep 17 00:00:00 2001 From: PancakeTAS Date: Thu, 25 Jun 2026 11:13:16 +0200 Subject: Bug fixes all across the project --- src/ioctl.cpp | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'src/ioctl.cpp') diff --git a/src/ioctl.cpp b/src/ioctl.cpp index 982e1e9..8b4962f 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -13,43 +13,35 @@ Exception::Exception(int fd, unsigned long op) : m_fd(fd), m_op(op), m_syserrno(errno) { switch (errno) { case EBADF: - m_code = Error::BadFileDescriptor; + this->m_code = Error::BadFileDescriptor; + this->m_what = std::format( + "ioctl({}, 0x{:x}) failed: Invalid file descriptor", + this->m_fd, this->m_op + ); break; case EINVAL: case ENOTTY: - m_code = Error::InvalidArgument; - break; - case ENOTSUP: - m_code = Error::NotSupported; - break; - default: - m_code = Error::Other; - } -} - -std::string Exception::readable() { - switch (this->m_code) { - case Error::BadFileDescriptor: - return std::format( - "ioctl({}, {}) failed: Invalid file descriptor", - this->m_fd, this->m_op - ); - case Error::InvalidArgument: - return std::format( - "ioctl({}, {}) failed: Invalid argument (errno {})", + this->m_code = Error::InvalidArgument; + this->m_what = std::format( + "ioctl({}, 0x{:x}) failed: Invalid argument (errno {})", this->m_fd, this->m_op, this->m_syserrno ); - case Error::NotSupported: - return std::format( - "ioctl({}, {}) failed: Operation not supported", + break; + case ENOTSUP: + this->m_code = Error::NotSupported; + this->m_what = std::format( + "ioctl({}, 0x{:x}) failed: Operation not supported", this->m_fd, this->m_op ); - case Error::Other: - return std::format( - "ioctl({}, {}) failed: Unknown error (errno {})", + break; + default: + this->m_code = Error::Other; + this->m_what = std::format( + "ioctl({}, 0x{:x}) failed: Unknown error (errno {})", this->m_fd, this->m_op, this->m_syserrno ); } } + Exception::~Exception() = default; -- cgit v1.3.1