diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-11-25 20:37:56 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-11-26 10:10:31 +0100 |
commit | 0947e097b1ef9feb4250eae071ac6ad7ffa7f14d (patch) | |
tree | ced07da074aee6af79e1b79f2e3ed67e5efcaa88 /common | |
parent | 5c14cd9f7ca1aeb19a7a69ab44e94f025ad39bf4 (diff) | |
download | tigervnc-0947e097b1ef9feb4250eae071ac6ad7ffa7f14d.tar.gz tigervnc-0947e097b1ef9feb4250eae071ac6ad7ffa7f14d.zip |
Mark all exception type methods as noexcept
This is required for the built in exceptions, so let's do the same to
avoid surprises.
Diffstat (limited to 'common')
-rw-r--r-- | common/rdr/Exception.cxx | 20 | ||||
-rw-r--r-- | common/rdr/Exception.h | 28 | ||||
-rw-r--r-- | common/rfb/Exception.h | 10 |
3 files changed, 30 insertions, 28 deletions
diff --git a/common/rdr/Exception.cxx b/common/rdr/Exception.cxx index 694ee359..f0c04a6a 100644 --- a/common/rdr/Exception.cxx +++ b/common/rdr/Exception.cxx @@ -43,21 +43,22 @@ using namespace rdr; -getaddrinfo_error::getaddrinfo_error(const char* s, int err_) +getaddrinfo_error::getaddrinfo_error(const char* s, int err_) noexcept : std::runtime_error(rfb::format("%s: %s (%d)", s, strerror(err_).c_str(), err_)), err(err_) { } -getaddrinfo_error::getaddrinfo_error(const std::string& s, int err_) +getaddrinfo_error::getaddrinfo_error(const std::string& s, + int err_) noexcept : std::runtime_error(rfb::format("%s: %s (%d)", s.c_str(), strerror(err_).c_str(), err_)), err(err_) { } -std::string getaddrinfo_error::strerror(int err_) const +std::string getaddrinfo_error::strerror(int err_) const noexcept { #ifdef _WIN32 char str[256]; @@ -71,21 +72,21 @@ std::string getaddrinfo_error::strerror(int err_) const #endif } -posix_error::posix_error(const char* what_arg, int err_) +posix_error::posix_error(const char* what_arg, int err_) noexcept : std::runtime_error(rfb::format("%s: %s (%d)", what_arg, strerror(err_).c_str(), err_)), err(err_) { } -posix_error::posix_error(const std::string& what_arg, int err_) +posix_error::posix_error(const std::string& what_arg, int err_) noexcept : std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(), strerror(err_).c_str(), err_)), err(err_) { } -std::string posix_error::strerror(int err_) const +std::string posix_error::strerror(int err_) const noexcept { #ifdef _WIN32 char str[256]; @@ -100,21 +101,22 @@ std::string posix_error::strerror(int err_) const } #ifdef WIN32 -win32_error::win32_error(const char* what_arg, unsigned err_) +win32_error::win32_error(const char* what_arg, unsigned err_) noexcept : std::runtime_error(rfb::format("%s: %s (%d)", what_arg, strerror(err_).c_str(), err_)), err(err_) { } -win32_error::win32_error(const std::string& what_arg, unsigned err_) +win32_error::win32_error(const std::string& what_arg, + unsigned err_) noexcept : std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(), strerror(err_).c_str(), err_)), err(err_) { } -std::string win32_error::strerror(unsigned err_) const +std::string win32_error::strerror(unsigned err_) const noexcept { wchar_t wstr[256]; char str[256]; diff --git a/common/rdr/Exception.h b/common/rdr/Exception.h index f3f878cb..d3cecc18 100644 --- a/common/rdr/Exception.h +++ b/common/rdr/Exception.h @@ -30,49 +30,49 @@ namespace rdr { class posix_error : public std::runtime_error { public: int err; - posix_error(const char* what_arg, int err_); - posix_error(const std::string& what_arg, int err_); + posix_error(const char* what_arg, int err_) noexcept; + posix_error(const std::string& what_arg, int err_) noexcept; private: - std::string strerror(int err_) const; + std::string strerror(int err_) const noexcept; }; #ifdef WIN32 class win32_error : public std::runtime_error { public: unsigned err; - win32_error(const char* what_arg, unsigned err_); - win32_error(const std::string& what_arg, unsigned err_); + win32_error(const char* what_arg, unsigned err_) noexcept; + win32_error(const std::string& what_arg, unsigned err_) noexcept; private: - std::string strerror(unsigned err_) const; + std::string strerror(unsigned err_) const noexcept; }; #endif #ifdef WIN32 class socket_error : public win32_error { public: - socket_error(const char* what_arg, unsigned err_) : win32_error(what_arg, err_) {} - socket_error(const std::string& what_arg, unsigned err_) : win32_error(what_arg, err_) {} + socket_error(const char* what_arg, unsigned err_) noexcept : win32_error(what_arg, err_) {} + socket_error(const std::string& what_arg, unsigned err_) noexcept : win32_error(what_arg, err_) {} }; #else class socket_error : public posix_error { public: - socket_error(const char* what_arg, unsigned err_) : posix_error(what_arg, err_) {} - socket_error(const std::string& what_arg, unsigned err_) : posix_error(what_arg, err_) {} + socket_error(const char* what_arg, unsigned err_) noexcept : posix_error(what_arg, err_) {} + socket_error(const std::string& what_arg, unsigned err_) noexcept : posix_error(what_arg, err_) {} }; #endif class getaddrinfo_error : public std::runtime_error { public: int err; - getaddrinfo_error(const char* s, int err_); - getaddrinfo_error(const std::string& s, int err_); + getaddrinfo_error(const char* s, int err_) noexcept; + getaddrinfo_error(const std::string& s, int err_) noexcept; private: - std::string strerror(int err_) const; + std::string strerror(int err_) const noexcept; }; class end_of_stream : public std::runtime_error { public: - end_of_stream() : std::runtime_error("End of stream") {} + end_of_stream() noexcept : std::runtime_error("End of stream") {} }; } diff --git a/common/rfb/Exception.h b/common/rfb/Exception.h index 0e74209c..b18f6d76 100644 --- a/common/rfb/Exception.h +++ b/common/rfb/Exception.h @@ -24,19 +24,19 @@ namespace rfb { class protocol_error : public std::runtime_error { public: - protocol_error(const char* what_arg) : std::runtime_error(what_arg) {} - protocol_error(const std::string& what_arg) : std::runtime_error(what_arg) {} + protocol_error(const char* what_arg) noexcept : std::runtime_error(what_arg) {} + protocol_error(const std::string& what_arg) noexcept : std::runtime_error(what_arg) {} }; class auth_error : public std::runtime_error { public: - auth_error(const char* reason) : std::runtime_error(reason) {} - auth_error(std::string& reason) : std::runtime_error(reason) {} + auth_error(const char* reason) noexcept : std::runtime_error(reason) {} + auth_error(std::string& reason) noexcept : std::runtime_error(reason) {} }; class auth_cancelled : public std::runtime_error { public: - auth_cancelled() + auth_cancelled() noexcept : std::runtime_error("Authentication cancelled") {} }; } |