aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-09-03 08:02:30 +0200
committerPierre Ossman <ossman@cendio.se>2024-11-06 21:18:52 +0100
commit1093b1eb6f3e561fb80aafba65e3f1505ae80350 (patch)
treefa1e47598653cefc6ba8eb2794065383b92c8cdd /common/rdr
parente4c60ef1985164d1207352bbfdf57ae1d7838404 (diff)
downloadtigervnc-1093b1eb6f3e561fb80aafba65e3f1505ae80350.tar.gz
tigervnc-1093b1eb6f3e561fb80aafba65e3f1505ae80350.zip
Replace base exception class with standard library
There is no point to having our own generic exception class. Let's use the one provided by the standard C++ library.
Diffstat (limited to 'common/rdr')
-rw-r--r--common/rdr/AESInStream.cxx4
-rw-r--r--common/rdr/Exception.cxx34
-rw-r--r--common/rdr/Exception.h37
-rw-r--r--common/rdr/TLSException.cxx3
-rw-r--r--common/rdr/TLSException.h3
5 files changed, 56 insertions, 25 deletions
diff --git a/common/rdr/AESInStream.cxx b/common/rdr/AESInStream.cxx
index d6d944a3..3a56ef73 100644
--- a/common/rdr/AESInStream.cxx
+++ b/common/rdr/AESInStream.cxx
@@ -21,8 +21,8 @@
#endif
#include <assert.h>
+
#include <rdr/AESInStream.h>
-#include <rdr/Exception.h>
#ifdef HAVE_NETTLE
using namespace rdr;
@@ -68,7 +68,7 @@ bool AESInStream::fillBuffer()
EAX_DIGEST(&eaxCtx256, aes256_encrypt, 16, macComputed);
}
if (memcmp(mac, macComputed, 16) != 0)
- throw Exception("AESInStream: failed to authenticate message");
+ throw std::runtime_error("AESInStream: failed to authenticate message");
in->setptr(2 + length + 16);
end += length;
diff --git a/common/rdr/Exception.cxx b/common/rdr/Exception.cxx
index b2c7e7d0..65bd9720 100644
--- a/common/rdr/Exception.cxx
+++ b/common/rdr/Exception.cxx
@@ -44,7 +44,15 @@ using namespace rdr;
GAIException::GAIException(const char* s, int err_)
- : Exception(rfb::format("%s: %s (%d)", s, strerror(err_).c_str(), err_)),
+ : std::runtime_error(rfb::format("%s: %s (%d)", s,
+ strerror(err_).c_str(), err_)),
+ err(err_)
+{
+}
+
+GAIException::GAIException(const std::string& s, int err_)
+ : std::runtime_error(rfb::format("%s: %s (%d)", s.c_str(),
+ strerror(err_).c_str(), err_)),
err(err_)
{
}
@@ -63,8 +71,16 @@ std::string GAIException::strerror(int err_) const
#endif
}
-PosixException::PosixException(const char* s, int err_)
- : Exception(rfb::format("%s: %s (%d)", s, strerror(err_).c_str(), err_)),
+PosixException::PosixException(const char* what_arg, int err_)
+ : std::runtime_error(rfb::format("%s: %s (%d)", what_arg,
+ strerror(err_).c_str(), err_)),
+ err(err_)
+{
+}
+
+PosixException::PosixException(const std::string& what_arg, int err_)
+ : std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(),
+ strerror(err_).c_str(), err_)),
err(err_)
{
}
@@ -84,8 +100,16 @@ std::string PosixException::strerror(int err_) const
}
#ifdef WIN32
-Win32Exception::Win32Exception(const char* s, unsigned err_)
- : Exception(rfb::format("%s: %s (%d)", s, strerror(err_).c_str(), err_)),
+Win32Exception::Win32Exception(const char* what_arg, unsigned err_)
+ : std::runtime_error(rfb::format("%s: %s (%d)", what_arg,
+ strerror(err_).c_str(), err_)),
+ err(err_)
+{
+}
+
+Win32Exception::Win32Exception(const std::string& what_arg, unsigned err_)
+ : std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(),
+ strerror(err_).c_str(), err_)),
err(err_)
{
}
diff --git a/common/rdr/Exception.h b/common/rdr/Exception.h
index 9ce0462a..3e0ec467 100644
--- a/common/rdr/Exception.h
+++ b/common/rdr/Exception.h
@@ -27,47 +27,52 @@
namespace rdr {
- class Exception : public std::runtime_error {
+ class PosixException : public std::runtime_error {
public:
- Exception(const char* what_arg) : std::runtime_error(what_arg) {}
- Exception(const std::string& what_arg) : std::runtime_error(what_arg) {}
- };
-
- struct PosixException : public Exception {
int err;
- PosixException(const char* s, int err_);
+ PosixException(const char* what_arg, int err_);
+ PosixException(const std::string& what_arg, int err_);
private:
std::string strerror(int err_) const;
};
#ifdef WIN32
- struct Win32Exception : public Exception {
+ class Win32Exception : public std::runtime_error {
+ public:
unsigned err;
- Win32Exception(const char* s, unsigned err_);
+ Win32Exception(const char* what_arg, unsigned err_);
+ Win32Exception(const std::string& what_arg, unsigned err_);
private:
std::string strerror(unsigned err_) const;
};
#endif
#ifdef WIN32
- struct SocketException : public Win32Exception {
- SocketException(const char* text, unsigned err_) : Win32Exception(text, err_) {}
+ class SocketException : public Win32Exception {
+ public:
+ SocketException(const char* what_arg, unsigned err_) : Win32Exception(what_arg, err_) {}
+ SocketException(const std::string& what_arg, unsigned err_) : Win32Exception(what_arg, err_) {}
};
#else
- struct SocketException : public PosixException {
- SocketException(const char* text, int err_) : PosixException(text, err_) {}
+ class SocketException : public PosixException {
+ public:
+ SocketException(const char* what_arg, unsigned err_) : PosixException(what_arg, err_) {}
+ SocketException(const std::string& what_arg, unsigned err_) : PosixException(what_arg, err_) {}
};
#endif
- struct GAIException : public Exception {
+ class GAIException : public std::runtime_error {
+ public:
int err;
GAIException(const char* s, int err_);
+ GAIException(const std::string& s, int err_);
private:
std::string strerror(int err_) const;
};
- struct EndOfStream : public Exception {
- EndOfStream() : Exception("End of stream") {}
+ class EndOfStream : public std::runtime_error {
+ public:
+ EndOfStream() : std::runtime_error("End of stream") {}
};
}
diff --git a/common/rdr/TLSException.cxx b/common/rdr/TLSException.cxx
index df2701d3..7061f38b 100644
--- a/common/rdr/TLSException.cxx
+++ b/common/rdr/TLSException.cxx
@@ -36,7 +36,8 @@ using namespace rdr;
#ifdef HAVE_GNUTLS
TLSException::TLSException(const char* s, int err_)
- : Exception(rfb::format("%s: %s (%d)", s, gnutls_strerror(err_), err_)),
+ : std::runtime_error(rfb::format("%s: %s (%d)", s,
+ gnutls_strerror(err_), err_)),
err(err_)
{
}
diff --git a/common/rdr/TLSException.h b/common/rdr/TLSException.h
index b519bfef..f58b618d 100644
--- a/common/rdr/TLSException.h
+++ b/common/rdr/TLSException.h
@@ -25,7 +25,8 @@
namespace rdr {
- struct TLSException : public Exception {
+ class TLSException : public std::runtime_error {
+ public:
int err;
TLSException(const char* s, int err_);
};