]> source.dussan.org Git - tigervnc.git/commitdiff
Use standard exception classes
authorPierre Ossman <ossman@cendio.se>
Mon, 2 Sep 2024 20:58:35 +0000 (22:58 +0200)
committerPierre Ossman <ossman@cendio.se>
Wed, 6 Nov 2024 20:06:27 +0000 (21:06 +0100)
Use the more specific already included exception classes for common
errors to keep things more understandable.

70 files changed:
common/network/Socket.cxx
common/network/TcpSocket.cxx
common/network/UnixSocket.cxx
common/rdr/BufferedInStream.cxx
common/rdr/BufferedOutStream.cxx
common/rdr/HexInStream.cxx
common/rdr/InStream.h
common/rdr/MemOutStream.h
common/rdr/OutStream.h
common/rdr/ZlibInStream.cxx
common/rdr/ZlibOutStream.cxx
common/rfb/CConnection.cxx
common/rfb/CMsgWriter.cxx
common/rfb/CSecurityDH.cxx
common/rfb/CSecurityMSLogonII.cxx
common/rfb/CSecurityRSAAES.cxx
common/rfb/CSecurityTLS.cxx
common/rfb/ClientParams.cxx
common/rfb/Configuration.cxx
common/rfb/Cursor.cxx
common/rfb/DecodeManager.cxx
common/rfb/EncodeManager.cxx
common/rfb/H264Decoder.cxx
common/rfb/H264DecoderContext.cxx
common/rfb/H264LibavDecoderContext.cxx
common/rfb/Hostname.h
common/rfb/JpegCompressor.cxx
common/rfb/JpegDecompressor.cxx
common/rfb/PixelBuffer.cxx
common/rfb/PixelFormat.cxx
common/rfb/SConnection.cxx
common/rfb/SMsgWriter.cxx
common/rfb/SSecurityPlain.cxx
common/rfb/SSecurityRSAAES.cxx
common/rfb/SSecurityVncAuth.cxx
common/rfb/SecurityClient.cxx
common/rfb/SecurityServer.cxx
common/rfb/ServerParams.cxx
common/rfb/VNCServerST.cxx
common/rfb/obfuscate.cxx
tests/perf/decperf.cxx
tests/perf/encperf.cxx
tests/unit/pixelformat.cxx
unix/tx/TXDialog.h
unix/x0vncserver/XDesktop.cxx
unix/xserver/hw/vnc/vncExtInit.cc
vncviewer/EmulateMB.cxx
vncviewer/PlatformPixelBuffer.cxx
vncviewer/ServerDialog.cxx
vncviewer/Surface_OSX.cxx
vncviewer/Surface_X11.cxx
vncviewer/Viewport.cxx
vncviewer/Win32TouchHandler.cxx
vncviewer/parameters.cxx
vncviewer/vncviewer.cxx
win/rfb_win32/CurrentUser.cxx
win/rfb_win32/DIBSectionBuffer.cxx
win/rfb_win32/DeviceContext.cxx
win/rfb_win32/DeviceFrameBuffer.cxx
win/rfb_win32/Dialog.cxx
win/rfb_win32/EventManager.cxx
win/rfb_win32/Registry.cxx
win/rfb_win32/SDisplay.cxx
win/rfb_win32/SDisplayCoreWMHooks.cxx
win/rfb_win32/Security.cxx
win/rfb_win32/SocketManager.cxx
win/rfb_win32/Win32Util.cxx
win/vncconfig/Legacy.cxx
win/winvnc/QueryConnectDialog.cxx
win/winvnc/winvnc.cxx

index 8bb96763718ac49733b0db2ab90a4eaa817ffc20..03844acd33569acfc2fcfbe6919de5b04d139a87 100644 (file)
@@ -39,6 +39,8 @@
 #include <fcntl.h>
 #include <errno.h>
 
+#include <rdr/Exception.h>
+
 #include <network/Socket.h>
 
 using namespace network;
index 38cb6eb386275fc6c1da693c624c149e7832a9e9..455df749b5b21d58f096330e9fc53238d95b2240 100644 (file)
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <rdr/Exception.h>
+
 #include <network/TcpSocket.h>
+
 #include <rfb/LogWriter.h>
 #include <rfb/Configuration.h>
 #include <rfb/util.h>
@@ -200,7 +203,7 @@ TcpSocket::TcpSocket(const char *host, int port)
 
   if (sock == -1) {
     if (err == 0)
-      throw Exception("No useful address for host");
+      throw std::runtime_error("No useful address for host");
     else
       throw SocketException("unable to connect to socket", err);
   }
@@ -607,7 +610,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
 
   parts = rfb::split(&p[1], '/');
   if (parts.size() > 2)
-    throw Exception("invalid filter specified");
+    throw std::invalid_argument("invalid filter specified");
 
   if (parts[0].empty()) {
     // Match any address
@@ -641,8 +644,8 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
     if (parts.size() > 1) {
       if (family == AF_INET &&
           (parts[1].find('.') != std::string::npos)) {
-        throw Exception("mask no longer supported for filter, "
-                        "use prefix instead");
+        throw std::invalid_argument("mask no longer supported for "
+                                    "filter, use prefix instead");
       }
 
       pattern.prefixlen = (unsigned int) atoi(parts[1].c_str());
@@ -655,7 +658,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
         pattern.prefixlen = 128;
         break;
       default:
-        throw Exception("unknown address family");
+        throw std::runtime_error("unknown address family");
       }
     }
   }
@@ -663,8 +666,9 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
   family = pattern.address.u.sa.sa_family;
 
   if (pattern.prefixlen > (family == AF_INET ? 32: 128))
-    throw Exception(rfb::format("invalid prefix length for filter address: %u",
-                                pattern.prefixlen));
+    throw std::invalid_argument(rfb::format("invalid prefix length for "
+                                            "filter address: %u",
+                                            pattern.prefixlen));
 
   // Compute mask from address and prefix length
   memset (&pattern.mask, 0, sizeof (pattern.mask));
index 3a422b6c211a5189e5ddd8e1533c41182b3623dc..4b82b4b728ed7f76f6f10834268efd3fbbcc4ba5 100644 (file)
 #include <stdlib.h>
 #include <stddef.h>
 
+#include <rdr/Exception.h>
+
 #include <network/UnixSocket.h>
+
 #include <rfb/LogWriter.h>
 
 using namespace network;
index 204202eca593a22f4120aead80c1def0ca17f542..bf94a9507a79aa2d36775cb3736f8b81a6880ed2 100644 (file)
@@ -24,7 +24,6 @@
 #include <assert.h>
 
 #include <rdr/BufferedInStream.h>
-#include <rdr/Exception.h>
 
 #include <rfb/util.h>
 
@@ -65,10 +64,12 @@ void BufferedInStream::ensureSpace(size_t needed)
     uint8_t* newBuffer;
 
     if (needed > MAX_BUF_SIZE)
-      throw Exception(rfb::format("BufferedInStream overrun: requested "
-                                  "size of %lu bytes exceeds maximum "
-                                  "of %lu bytes", (long unsigned)needed,
-                                  (long unsigned)MAX_BUF_SIZE));
+      throw std::out_of_range(rfb::format("BufferedInStream overrun: "
+                                          "requested size of %lu bytes "
+                                          "exceeds maximum of %lu "
+                                          "bytes",
+                                          (long unsigned)needed,
+                                          (long unsigned)MAX_BUF_SIZE));
 
     newSize = DEFAULT_BUF_SIZE;
     while (newSize < needed)
index f5062bf2cecffade96db9d10d4daa127fd9ecb41..efb71dd7d90af2ca8e9325b4f9f15dd8e7ef5b65 100644 (file)
@@ -23,7 +23,6 @@
 #endif
 
 #include <rdr/BufferedOutStream.h>
-#include <rdr/Exception.h>
 
 #include <rfb/util.h>
 
@@ -139,10 +138,11 @@ void BufferedOutStream::overrun(size_t needed)
   // We'll need to allocate more buffer space...
 
   if (totalNeeded > MAX_BUF_SIZE)
-    throw Exception(rfb::format("BufferedOutStream overrun: requested "
-                                "size of %lu bytes exceeds maximum of "
-                                "%lu bytes", (long unsigned)totalNeeded,
-                                (long unsigned)MAX_BUF_SIZE));
+    throw std::out_of_range(rfb::format("BufferedOutStream overrun: "
+                                        "requested size of %lu bytes "
+                                        "exceeds maximum of %lu bytes",
+                                        (long unsigned)totalNeeded,
+                                        (long unsigned)MAX_BUF_SIZE));
 
   newSize = DEFAULT_BUF_SIZE;
   while (newSize < totalNeeded)
index 11f98498eea8f76856c7f2ebba1c9ad44d788f6b..69c3e260847aa5b3eb2261ef239bb5cbc05f34c5 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <algorithm>
 #include <rdr/HexInStream.h>
-#include <rdr/Exception.h>
 #include <rfb/util.h>
 
 using namespace rdr;
@@ -46,7 +45,7 @@ bool HexInStream::fillBuffer() {
   uint8_t* optr = (uint8_t*) end;
   for (size_t i=0; i<length; i++) {
     if (!rfb::hexToBin((const char*)&iptr[i*2], 2, &optr[i], 1))
-      throw Exception("HexInStream: Invalid input data");
+      throw std::runtime_error("HexInStream: Invalid input data");
   }
 
   in_stream.setptr(length*2);
index 939439e1ba03d24483894578f28ad80821e36191..5623142c5d8d0e98215dbc38a781d07bdb4f3d35 100644 (file)
@@ -28,7 +28,7 @@
 #include <stdint.h>
 #include <string.h> // for memcpy
 
-#include <rdr/Exception.h>
+#include <stdexcept>
 
 // Check that callers are using InStream properly,
 // useful when writing new protocol handling
@@ -101,21 +101,21 @@ namespace rdr {
     inline void setRestorePoint() {
 #ifdef RFB_INSTREAM_CHECK
       if (restorePoint != nullptr)
-        throw Exception("Nested use of input stream restore point");
+        throw std::logic_error("Nested use of input stream restore point");
 #endif
       restorePoint = ptr;
     }
     inline void clearRestorePoint() {
 #ifdef RFB_INSTREAM_CHECK
       if (restorePoint == nullptr)
-        throw Exception("Incorrect clearing of input stream restore point");
+        throw std::logic_error("Incorrect clearing of input stream restore point");
 #endif
       restorePoint = nullptr;
     }
     inline void gotoRestorePoint() {
 #ifdef RFB_INSTREAM_CHECK
       if (restorePoint == nullptr)
-        throw Exception("Incorrect activation of input stream restore point");
+        throw std::logic_error("Incorrect activation of input stream restore point");
 #endif
       ptr = restorePoint;
       clearRestorePoint();
@@ -176,7 +176,7 @@ namespace rdr {
     inline const uint8_t* getptr(size_t length) { check(length);
                                                   return ptr; }
     inline void setptr(size_t length) { if (length > avail())
-                                          throw Exception("Input stream overflow");
+                                          throw std::out_of_range("Input stream overflow");
                                         skip(length); }
 
   private:
@@ -189,11 +189,11 @@ namespace rdr {
     inline void check(size_t bytes) {
 #ifdef RFB_INSTREAM_CHECK
       if (bytes > checkedBytes)
-        throw Exception("Input stream used without underrun check");
+        throw std::logic_error("Input stream used without underrun check");
       checkedBytes -= bytes;
 #endif
       if (bytes > (size_t)(end - ptr))
-        throw Exception("InStream buffer underrun");
+        throw std::out_of_range("InStream buffer underrun");
     }
 
     // overrun() is implemented by a derived class to cope with buffer overrun.
index 9bf2b810fc29b4d627874e015ab59cc8cef9aa79..bf05d92cb8cfad7f4e5791d60540cef070405be9 100644 (file)
@@ -23,7 +23,6 @@
 #ifndef __RDR_MEMOUTSTREAM_H__
 #define __RDR_MEMOUTSTREAM_H__
 
-#include <rdr/Exception.h>
 #include <rdr/OutStream.h>
 
 namespace rdr {
@@ -61,7 +60,7 @@ namespace rdr {
         len = (end - start) * 2;
 
       if (len < (size_t)(end - start))
-        throw Exception("Overflow in MemOutStream::overrun()");
+        throw std::out_of_range("Overflow in MemOutStream::overrun()");
 
       uint8_t* newStart = new uint8_t[len];
       memcpy(newStart, start, ptr - start);
index 2921b2326558e0dc47458d48f61baa7a3a58ba31..b78ec4b069a972e14d1df2de6fa8710ee47b255a 100644 (file)
@@ -27,7 +27,8 @@
 #include <stdint.h>
 #include <string.h> // for memcpy
 
-#include <rdr/Exception.h>
+#include <stdexcept>
+
 #include <rdr/InStream.h>
 
 namespace rdr {
@@ -129,7 +130,7 @@ namespace rdr {
 
     inline uint8_t* getptr(size_t length) { check(length); return ptr; }
     inline void setptr(size_t length) { if (length > avail())
-                                          throw Exception("Output stream overflow");
+                                          throw std::out_of_range("Output stream overflow");
                                         ptr += length; }
 
   private:
index a90d50f7540b85d086ec397dc5f9df83f4dfe139..c9f8aecaa3b470ede74b880e59d4168dd0ba2020 100644 (file)
@@ -23,7 +23,6 @@
 #include <assert.h>
 
 #include <rdr/ZlibInStream.h>
-#include <rdr/Exception.h>
 #include <zlib.h>
 
 using namespace rdr;
@@ -50,7 +49,7 @@ void ZlibInStream::flushUnderlying()
 {
   while (bytesIn > 0) {
     if (!hasData(1))
-      throw Exception("ZlibInStream: failed to flush remaining stream data");
+      throw std::runtime_error("ZlibInStream: failed to flush remaining stream data");
     skip(avail());
   }
 
@@ -76,7 +75,7 @@ void ZlibInStream::init()
   if (inflateInit(zs) != Z_OK) {
     delete zs;
     zs = nullptr;
-    throw Exception("ZlibInStream: inflateInit failed");
+    throw std::runtime_error("ZlibInStream: inflateInit failed");
   }
 }
 
@@ -92,7 +91,7 @@ void ZlibInStream::deinit()
 bool ZlibInStream::fillBuffer()
 {
   if (!underlying)
-    throw Exception("ZlibInStream overrun: no underlying stream");
+    throw std::runtime_error("ZlibInStream overrun: no underlying stream");
 
   zs->next_out = (uint8_t*)end;
   zs->avail_out = availSpace();
@@ -107,7 +106,7 @@ bool ZlibInStream::fillBuffer()
 
   int rc = inflate(zs, Z_SYNC_FLUSH);
   if (rc < 0) {
-    throw Exception("ZlibInStream: inflate failed");
+    throw std::runtime_error("ZlibInStream: inflate failed");
   }
 
   bytesIn -= length - zs->avail_in;
index 1b59f54eb92a672da153b497a58479cbf3a6486b..13788f8db2ecca9f458dd67f7c683084146b47e3 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdio.h>
 
 #include <rdr/ZlibOutStream.h>
-#include <rdr/Exception.h>
 #include <rfb/LogWriter.h>
 
 #include <zlib.h>
@@ -46,7 +45,7 @@ ZlibOutStream::ZlibOutStream(OutStream* os, int compressLevel)
   zs->avail_in  = 0;
   if (deflateInit(zs, compressLevel) != Z_OK) {
     delete zs;
-    throw Exception("ZlibOutStream: deflateInit failed");
+    throw std::runtime_error("ZlibOutStream: deflateInit failed");
   }
 }
 
@@ -113,7 +112,7 @@ void ZlibOutStream::deflate(int flush)
   int rc;
 
   if (!underlying)
-    throw Exception("ZlibOutStream: underlying OutStream has not been set");
+    throw std::runtime_error("ZlibOutStream: underlying OutStream has not been set");
 
   if ((flush == Z_NO_FLUSH) && (zs->avail_in == 0))
     return;
@@ -134,7 +133,7 @@ void ZlibOutStream::deflate(int flush)
       if ((rc == Z_BUF_ERROR) && (flush != Z_NO_FLUSH))
         break;
 
-      throw Exception("ZlibOutStream: deflate failed");
+      throw std::runtime_error("ZlibOutStream: deflate failed");
     }
 
 #ifdef ZLIBOUT_DEBUG
@@ -168,7 +167,7 @@ void ZlibOutStream::checkCompressionLevel()
       // explicit flush we did above. It should be safe to ignore though
       // as the first flush should have left things in a stable state...
       if (rc != Z_BUF_ERROR)
-        throw Exception("ZlibOutStream: deflateParams failed");
+        throw std::runtime_error("ZlibOutStream: deflateParams failed");
     }
 
     compressionLevel = newLevel;
index 3a34740f215bf5b809d90136c32cfeb0d2a03864..244c88622c2aa19575e32c0b64a13b3c6965f327 100644 (file)
@@ -147,11 +147,11 @@ bool CConnection::processMsg()
   case RFBSTATE_INITIALISATION:   return processInitMsg();           break;
   case RFBSTATE_NORMAL:           return reader_->readMsg();         break;
   case RFBSTATE_CLOSING:
-    throw Exception("CConnection::processMsg: called while closing");
+    throw std::logic_error("CConnection::processMsg: called while closing");
   case RFBSTATE_UNINITIALISED:
-    throw Exception("CConnection::processMsg: not initialised yet?");
+    throw std::logic_error("CConnection::processMsg: not initialised yet?");
   default:
-    throw Exception("CConnection::processMsg: invalid state");
+    throw std::logic_error("CConnection::processMsg: invalid state");
   }
 }
 
index 1bd8040f7ab478a1d4eef2155e939df0b27db760..1c801412ce029daf5b49b38d9b24315759900e3d 100644 (file)
@@ -31,7 +31,6 @@
 #include <rfb/fenceTypes.h>
 #include <rfb/qemuTypes.h>
 #include <rfb/clipboardTypes.h>
-#include <rfb/Exception.h>
 #include <rfb/PixelFormat.h>
 #include <rfb/Rect.h>
 #include <rfb/ServerParams.h>
@@ -77,7 +76,7 @@ void CMsgWriter::writeSetDesktopSize(int width, int height,
                                      const ScreenSet& layout)
 {
   if (!server->supportsSetDesktopSize)
-    throw Exception("Server does not support SetDesktopSize");
+    throw std::logic_error("Server does not support SetDesktopSize");
 
   startMsg(msgTypeSetDesktopSize);
   os->pad(1);
@@ -116,7 +115,7 @@ void CMsgWriter::writeEnableContinuousUpdates(bool enable,
                                               int x, int y, int w, int h)
 {
   if (!server->supportsContinuousUpdates)
-    throw Exception("Server does not support continuous updates");
+    throw std::logic_error("Server does not support continuous updates");
 
   startMsg(msgTypeEnableContinuousUpdates);
 
@@ -133,11 +132,11 @@ void CMsgWriter::writeEnableContinuousUpdates(bool enable,
 void CMsgWriter::writeFence(uint32_t flags, unsigned len, const uint8_t data[])
 {
   if (!server->supportsFence)
-    throw Exception("Server does not support fences");
+    throw std::logic_error("Server does not support fences");
   if (len > 64)
-    throw Exception("Too large fence payload");
+    throw std::out_of_range("Too large fence payload");
   if ((flags & ~fenceFlagsSupported) != 0)
-    throw Exception("Unknown fence flags");
+    throw std::invalid_argument("Unknown fence flags");
 
   startMsg(msgTypeClientFence);
   os->pad(3);
@@ -192,7 +191,7 @@ void CMsgWriter::writePointerEvent(const Point& pos, uint8_t buttonMask)
 void CMsgWriter::writeClientCutText(const char* str)
 {
   if (strchr(str, '\r') != nullptr)
-    throw Exception("Invalid carriage return in clipboard data");
+    throw std::invalid_argument("Invalid carriage return in clipboard data");
 
   std::string latin1(utf8ToLatin1(str));
 
@@ -209,7 +208,7 @@ void CMsgWriter::writeClipboardCaps(uint32_t caps,
   size_t i, count;
 
   if (!(server->clipboardFlags() & clipboardCaps))
-    throw Exception("Server does not support clipboard \"caps\" action");
+    throw std::logic_error("Server does not support clipboard \"caps\" action");
 
   count = 0;
   for (i = 0;i < 16;i++) {
@@ -235,7 +234,7 @@ void CMsgWriter::writeClipboardCaps(uint32_t caps,
 void CMsgWriter::writeClipboardRequest(uint32_t flags)
 {
   if (!(server->clipboardFlags() & clipboardRequest))
-    throw Exception("Server does not support clipboard \"request\" action");
+    throw std::logic_error("Server does not support clipboard \"request\" action");
 
   startMsg(msgTypeClientCutText);
   os->pad(3);
@@ -247,7 +246,7 @@ void CMsgWriter::writeClipboardRequest(uint32_t flags)
 void CMsgWriter::writeClipboardPeek(uint32_t flags)
 {
   if (!(server->clipboardFlags() & clipboardPeek))
-    throw Exception("Server does not support clipboard \"peek\" action");
+    throw std::logic_error("Server does not support clipboard \"peek\" action");
 
   startMsg(msgTypeClientCutText);
   os->pad(3);
@@ -259,7 +258,7 @@ void CMsgWriter::writeClipboardPeek(uint32_t flags)
 void CMsgWriter::writeClipboardNotify(uint32_t flags)
 {
   if (!(server->clipboardFlags() & clipboardNotify))
-    throw Exception("Server does not support clipboard \"notify\" action");
+    throw std::logic_error("Server does not support clipboard \"notify\" action");
 
   startMsg(msgTypeClientCutText);
   os->pad(3);
@@ -278,7 +277,7 @@ void CMsgWriter::writeClipboardProvide(uint32_t flags,
   int i, count;
 
   if (!(server->clipboardFlags() & clipboardProvide))
-    throw Exception("Server does not support clipboard \"provide\" action");
+    throw std::logic_error("Server does not support clipboard \"provide\" action");
 
   zos.setUnderlying(&mos);
 
index 6eafbd9ca5aaba270f629bc61f36ac893e62cc8a..e37a3a3391b5ec3a69cdd2a52940c420d32bfc1c 100644 (file)
@@ -112,7 +112,7 @@ void CSecurityDH::writeCredentials()
 
   std::vector<uint8_t> bBytes(keyLength);
   if (!rs.hasData(keyLength))
-    throw Exception("failed to generate DH private key");
+    throw std::runtime_error("failed to generate DH private key");
   rs.readBytes(bBytes.data(), bBytes.size());
   nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
   mpz_powm(k, A, b, p);
@@ -132,13 +132,13 @@ void CSecurityDH::writeCredentials()
 
   uint8_t buf[128];
   if (!rs.hasData(128))
-    throw Exception("failed to generate random padding");
+    throw std::runtime_error("failed to generate random padding");
   rs.readBytes(buf, 128);
   if (username.size() >= 64)
-    throw Exception("username is too long");
+    throw std::out_of_range("username is too long");
   memcpy(buf, username.c_str(), username.size() + 1);
   if (password.size() >= 64)
-    throw Exception("password is too long");
+    throw std::out_of_range("password is too long");
   memcpy(buf + 64, password.c_str(), password.size() + 1);
   aes128_encrypt(&aesCtx, 128, buf, buf);
 
index f8ff36c1557517dcfd049b7cf3047b4b785c260b..85736b44f007e7e23e75ec063755e29c87e741d6 100644 (file)
@@ -39,7 +39,6 @@
 #include <rdr/InStream.h>
 #include <rdr/OutStream.h>
 #include <rdr/RandomStream.h>
-#include <rfb/Exception.h>
 #include <os/os.h>
 
 using namespace rfb;
@@ -101,7 +100,7 @@ void CSecurityMSLogonII::writeCredentials()
 
   std::vector<uint8_t> bBytes(8);
   if (!rs.hasData(8))
-    throw Exception("failed to generate DH private key");
+    throw std::runtime_error("failed to generate DH private key");
   rs.readBytes(bBytes.data(), bBytes.size());
   nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
   mpz_powm(k, A, b, p);
@@ -123,14 +122,14 @@ void CSecurityMSLogonII::writeCredentials()
   }
 
   if (!rs.hasData(256 + 64))
-    throw Exception("failed to generate random padding");
+    throw std::runtime_error("failed to generate random padding");
   rs.readBytes(user, 256);
   rs.readBytes(pass, 64);
   if (username.size() >= 256)
-    throw Exception("username is too long");
+    throw std::out_of_range("username is too long");
   memcpy(user, username.c_str(), username.size() + 1);
   if (password.size() >= 64)
-    throw Exception("password is too long");
+    throw std::out_of_range("password is too long");
   memcpy(pass, password.c_str(), password.size() + 1);
 
   // DES-CBC with the original key as IV, and the reversed one as the DES key
index 4baeb235c21dfa582fccc577a3c08466db7ae142..37b595321e004bccdf2a5cf011ac497334911beb 100644 (file)
@@ -134,7 +134,7 @@ static void random_func(void* ctx, size_t length, uint8_t* dst)
 {
   rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
   if (!rs->hasData(length))
-    throw Exception("failed to generate random");
+    throw std::runtime_error("failed to generate random");
   rs->readBytes(dst, length);
 }
 
@@ -155,7 +155,7 @@ void CSecurityRSAAES::writePublicKey()
   if (!rsa_generate_keypair(&clientPublicKey, &clientKey,
                             &rs, random_func, nullptr, nullptr,
                             clientKeyLength, 0))
-    throw Exception("failed to generate key");
+    throw std::runtime_error("failed to generate key");
   clientKeyN = new uint8_t[rsaKeySize];
   clientKeyE = new uint8_t[rsaKeySize];
   nettle_mpz_get_str_256(rsaKeySize, clientKeyN, clientPublicKey.n);
@@ -222,7 +222,7 @@ void CSecurityRSAAES::writeRandom()
 {
   rdr::OutStream* os = cc->getOutStream();
   if (!rs.hasData(keySize / 8))
-    throw Exception("failed to generate random");
+    throw std::runtime_error("failed to generate random");
   rs.readBytes(clientRandom, keySize / 8);
   mpz_t x;
   mpz_init(x);
@@ -236,7 +236,7 @@ void CSecurityRSAAES::writeRandom()
   }
   if (!res) {
     mpz_clear(x);
-    throw Exception("failed to encrypt random");
+    throw std::runtime_error("failed to encrypt random");
   }
   uint8_t* buffer = new uint8_t[serverKey.size];
   nettle_mpz_get_str_256(serverKey.size, buffer, x);
@@ -443,7 +443,7 @@ void CSecurityRSAAES::writeCredentials()
 
   if (subtype == secTypeRA2UserPass) {
     if (username.size() > 255)
-      throw Exception("username is too long");
+      throw std::out_of_range("username is too long");
     raos->writeU8(username.size());
     raos->writeBytes((const uint8_t*)username.data(), username.size());
   } else {
@@ -451,7 +451,7 @@ void CSecurityRSAAES::writeCredentials()
   }
 
   if (password.size() > 255)
-    throw Exception("password is too long");
+    throw std::out_of_range("password is too long");
   raos->writeU8(password.size());
   raos->writeBytes((const uint8_t*)password.data(), password.size());
   raos->flush();
index 2722415b5d40134e7bab9b18830722fe49304e37..ae916139edf5681553b96eba14f4843b6e280887 100644 (file)
@@ -387,8 +387,8 @@ void CSecurityTLS::checkSession()
 
   hostsDir = os::getvncstatedir();
   if (hostsDir == nullptr) {
-    throw Exception("Could not obtain VNC state directory path for "
-                    "known hosts storage");
+    throw std::runtime_error("Could not obtain VNC state directory "
+                             "path for known hosts storage");
   }
 
   std::string dbPath;
@@ -509,7 +509,7 @@ void CSecurityTLS::checkSession()
 
     if (status != 0) {
       vlog.error("Unhandled certificate problems: 0x%x", status);
-      throw Exception("Unhandled certificate problems");
+      throw std::logic_error("Unhandled certificate problems");
     }
 
     if (!hostname_match) {
@@ -625,7 +625,7 @@ void CSecurityTLS::checkSession()
 
     if (status != 0) {
       vlog.error("Unhandled certificate problems: 0x%x", status);
-      throw Exception("Unhandled certificate problems");
+      throw std::logic_error("Unhandled certificate problems");
     }
 
     if (!hostname_match) {
index 3f80f10954a237f71bf228a27bb03217d4d6ded8..495b4bd127334f6071529c1b3a92e2120a7f1c3a 100644 (file)
@@ -22,7 +22,8 @@
 #include <config.h>
 #endif
 
-#include <rfb/Exception.h>
+#include <stdexcept>
+
 #include <rfb/encodings.h>
 #include <rfb/ledStates.h>
 #include <rfb/clipboardTypes.h>
@@ -63,7 +64,7 @@ void ClientParams::setDimensions(int width, int height)
 void ClientParams::setDimensions(int width, int height, const ScreenSet& layout)
 {
   if (!layout.validate(width, height))
-    throw Exception("Attempted to configure an invalid screen layout");
+    throw std::invalid_argument("Attempted to configure an invalid screen layout");
 
   width_ = width;
   height_ = height;
@@ -75,7 +76,7 @@ void ClientParams::setPF(const PixelFormat& pf)
   pf_ = pf;
 
   if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
-    throw Exception("setPF: not 8, 16 or 32 bpp?");
+    throw std::invalid_argument("setPF: not 8, 16 or 32 bpp?");
 }
 
 void ClientParams::setName(const char* name)
@@ -161,7 +162,7 @@ uint32_t ClientParams::clipboardSize(unsigned int format) const
       return clipSizes[i];
   }
 
-  throw Exception(rfb::format("Invalid clipboard format 0x%x", format));
+  throw std::invalid_argument(rfb::format("Invalid clipboard format 0x%x", format));
 }
 
 void ClientParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
index f58a9c2f9de9536a593b5545e45d727bd17963ff..8f7cb6a7697256b1349ea4d134451acb24a48136 100644 (file)
 #include <ctype.h>
 #include <string.h>
 
+#include <stdexcept>
+
 #include <os/Mutex.h>
 
 #include <rfb/util.h>
 #include <rfb/Configuration.h>
 #include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
 
 #define LOCK_CONFIG os::AutoMutex a(mutex)
 
@@ -376,7 +377,7 @@ StringParameter::StringParameter(const char* name_, const char* desc_,
 {
   if (!v) {
     vlog.error("Default value <null> for %s not allowed",name_);
-    throw rfb::Exception("Default value <null> not allowed");
+    throw std::invalid_argument("Default value <null> not allowed");
   }
 }
 
@@ -387,7 +388,7 @@ bool StringParameter::setParam(const char* v) {
   LOCK_CONFIG;
   if (immutable) return true;
   if (!v)
-    throw rfb::Exception("setParam(<null>) not allowed");
+    throw std::invalid_argument("setParam(<null>) not allowed");
   vlog.debug("set %s(String) to %s", getName(), v);
   value = v;
   return true;
index fa596bc5b659e4b4d0304bab11bc4733599b99ca..94844144156d513af99caa53e5a3ffaa1c5febc9 100644 (file)
 #include <assert.h>
 #include <string.h>
 
+#include <stdexcept>
+
 #include <rfb/Cursor.h>
 #include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
 
 using namespace rfb;
 
@@ -260,7 +261,7 @@ const uint8_t* RenderedCursor::getBuffer(const Rect& _r, int* stride) const
 
   r = _r.translate(offset.negate());
   if (!r.enclosed_by(buffer.getRect()))
-    throw Exception("RenderedCursor: Invalid area requested");
+    throw std::out_of_range("RenderedCursor: Invalid area requested");
 
   return buffer.getBuffer(r, stride);
 }
index 6000063f3bf21eaec82a6f64207ccf730acb5ac2..2b121ebe81af4f4fe300055563a166d97ba8ff9b 100644 (file)
@@ -149,7 +149,7 @@ bool DecodeManager::decodeRect(const Rect& r, int encoding,
     if (!decoder->readRect(r, conn->getInStream(), conn->server, bufferStream))
       return false;
   } catch (std::exception& e) {
-    throw Exception(format("Error reading rect: %s", e.what()));
+    throw std::runtime_error(format("Error reading rect: %s", e.what()));
   }
 
   stats[encoding].rects++;
@@ -250,7 +250,7 @@ void DecodeManager::setThreadException(const std::exception& e)
   if (threadException != nullptr)
     return;
 
-  threadException = new rdr::Exception(format("Exception on worker thread: %s", e.what()));
+  threadException = new std::runtime_error(format("Exception on worker thread: %s", e.what()));
 }
 
 void DecodeManager::throwThreadException()
index 5c1429d2afee91bddfde4159fb99c950f98174bd..4526c0b3e09ae9615b4fd6819d15e9a4af3c132e 100644 (file)
@@ -32,7 +32,6 @@
 #include <rfb/SMsgWriter.h>
 #include <rfb/UpdateTracker.h>
 #include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
 #include <rfb/util.h>
 
 #include <rfb/RawEncoder.h>
@@ -1055,7 +1054,7 @@ void EncodeManager::OffsetPixelBuffer::update(const PixelFormat& pf,
 
 uint8_t* EncodeManager::OffsetPixelBuffer::getBufferRW(const Rect& /*r*/, int* /*stride*/)
 {
-  throw rfb::Exception("Invalid write attempt to OffsetPixelBuffer");
+  throw std::logic_error("Invalid write attempt to OffsetPixelBuffer");
 }
 
 template<class T>
index 3178a17beab0758c71e8561e3f757a50d4a00ae3..89850ba47031b08159003b747e762b9058b02080 100644 (file)
@@ -30,7 +30,6 @@
 #include <rdr/InStream.h>
 #include <rdr/OutStream.h>
 #include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
 #include <rfb/H264Decoder.h>
 #include <rfb/H264DecoderContext.h>
 
@@ -128,12 +127,12 @@ void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
     }
     ctx = H264DecoderContext::createContext(r);
     if (!ctx)
-      throw Exception("H264Decoder: Context not be created");
+      throw std::runtime_error("H264Decoder: Context not be created");
     contexts.push_back(ctx);
   }
 
   if (!ctx->isReady())
-    throw Exception("H264Decoder: Context is not ready");
+    throw std::runtime_error("H264Decoder: Context is not ready");
 
   if (reset & resetContext)
     ctx->reset();
index 87ac0d8535b0f5e3b4e1c9735f418c11b7c6ed23..b2054554e732fad753837a6f5e297555a1cb518e 100644 (file)
@@ -22,8 +22,9 @@
 #include <config.h>
 #endif
 
+#include <stdexcept>
+
 #include <os/Mutex.h>
-#include <rfb/Exception.h>
 #include <rfb/LogWriter.h>
 
 #include <rfb/H264DecoderContext.h>
@@ -45,7 +46,7 @@ H264DecoderContext *H264DecoderContext::createContext(const Rect &r)
   H264DecoderContext *ret = new H264DecoderContextType(r);
   if (!ret->initCodec())
   {
-    throw Exception("H264DecoderContext: Unable to create context");
+    throw std::runtime_error("H264DecoderContext: Unable to create context");
   }
 
   return ret;
index fa2f367b3f5a08e332744a98fd990fd66f5c812c..2d8d03e7d62111f5cc406b3a84e2880e5b503cb8 100644 (file)
@@ -33,7 +33,6 @@ extern "C" {
 #define FFMPEG_INIT_PACKET_DEPRECATED
 #endif
 
-#include <rfb/Exception.h>
 #include <rfb/LogWriter.h>
 #include <rfb/PixelBuffer.h>
 #include <rfb/H264LibavDecoderContext.h>
@@ -118,7 +117,7 @@ uint8_t* H264LibavDecoderContext::makeH264WorkBuffer(const uint8_t* buffer, uint
   {
     h264WorkBuffer = (uint8_t*)realloc(h264WorkBuffer, reserve_len);
     if (h264WorkBuffer == nullptr) {
-      throw Exception("H264LibavDecoderContext: Unable to allocate memory");
+      throw std::bad_alloc();
     }
     h264WorkBufferLength = reserve_len;
   }
index f6a11a60536f29e339ec4eca7ec4f2faf5af7bf5..de4a330e65afd7fbeedd834835f17c776073f56e 100644 (file)
@@ -23,7 +23,9 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
-#include <rdr/Exception.h>
+
+#include <stdexcept>
+
 #include <rfb/util.h>
 
 namespace rfb {
@@ -47,7 +49,7 @@ namespace rfb {
     const char* portStart;
 
     if (hi == nullptr)
-      throw rdr::Exception("NULL host specified");
+      throw std::invalid_argument("NULL host specified");
 
     // Trim leading whitespace
     while(isspace(*hi))
@@ -60,7 +62,7 @@ namespace rfb {
       hostStart = &hi[1];
       hostEnd = strchr(hostStart, ']');
       if (hostEnd == nullptr)
-        throw rdr::Exception("unmatched [ in host");
+        throw std::invalid_argument("unmatched [ in host");
 
       portStart = hostEnd + 1;
       if (isAllSpace(portStart))
@@ -99,14 +101,14 @@ namespace rfb {
       char* end;
 
       if (portStart[0] != ':')
-        throw rdr::Exception("invalid port specified");
+        throw std::invalid_argument("invalid port specified");
 
       if (portStart[1] != ':')
         *port = strtol(portStart + 1, &end, 10);
       else
         *port = strtol(portStart + 2, &end, 10);
       if (*end != '\0' && ! isAllSpace(end))
-        throw rdr::Exception("invalid port specified");
+        throw std::invalid_argument("invalid port specified");
 
       if ((portStart[1] != ':') && (*port < 100))
         *port += basePort;
index 49ed4b61eadf9299bb718017bbcbf720319d9a61..67a86cd932b32f982bba05efce394fa5e3bc728c 100644 (file)
@@ -22,8 +22,9 @@
 #include <config.h>
 #endif
 
+#include <stdexcept>
+
 #include <rfb/JpegCompressor.h>
-#include <rdr/Exception.h>
 #include <rfb/Rect.h>
 #include <rfb/PixelFormat.h>
 #include <rfb/ClientParams.h>
@@ -127,7 +128,7 @@ JpegCompressor::JpegCompressor(int bufferLen) : MemOutStream(bufferLen)
 
   if(setjmp(err->jmpBuffer)) {
     // this will execute if libjpeg has an error
-    throw rdr::Exception(err->lastError);
+    throw std::runtime_error(err->lastError);
   }
 
   jpeg_create_compress(cinfo);
@@ -171,7 +172,7 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride,
     jpeg_abort_compress(cinfo);
     if (srcBufIsTemp && srcBuf) delete[] srcBuf;
     if (rowPointer) delete[] rowPointer;
-    throw rdr::Exception(err->lastError);
+    throw std::runtime_error(err->lastError);
   }
 
   cinfo->image_width = w;
@@ -256,5 +257,5 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride,
 
 void JpegCompressor::writeBytes(const uint8_t* /*data*/, int /*length*/)
 {
-  throw rdr::Exception("writeBytes() is not valid with a JpegCompressor instance.  Use compress() instead.");
+  throw std::logic_error("writeBytes() is not valid with a JpegCompressor instance.  Use compress() instead.");
 }
index 4b3b4db7fec05aae802dd2b2d438bd9c23becf7f..9406b43d5e4c4057e71152686d525deb93327318 100644 (file)
@@ -120,7 +120,7 @@ JpegDecompressor::JpegDecompressor(void)
 
   if(setjmp(err->jmpBuffer)) {
     // this will execute if libjpeg has an error
-    throw rdr::Exception(err->lastError);
+    throw std::runtime_error(err->lastError);
   }
 
   jpeg_create_decompress(dinfo);
@@ -168,7 +168,7 @@ void JpegDecompressor::decompress(const uint8_t *jpegBuf,
     jpeg_abort_decompress(dinfo);
     if (dstBufIsTemp && dstBuf) delete[] dstBuf;
     if (rowPointer) delete[] rowPointer;
-    throw rdr::Exception(err->lastError);
+    throw std::runtime_error(err->lastError);
   }
 
   src->pub.next_input_byte = jpegBuf;
index ca2a584502f948bacf20f6e065da6f5a09f8cfb5..5590c2140705bf930f80b2470092fb223e9e5e27 100644 (file)
@@ -28,7 +28,8 @@
 
 #include <string.h>
 
-#include <rfb/Exception.h>
+#include <stdexcept>
+
 #include <rfb/LogWriter.h>
 #include <rfb/PixelBuffer.h>
 #include <rfb/util.h>
@@ -71,10 +72,10 @@ PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) const
   const uint8_t* end;
 
   if (!r.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     r.width(), r.height(),
-                                     r.tl.x, r.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        r.width(), r.height(),
+                                        r.tl.x, r.tl.y,
+                                        width(), height()));
 
   data = getBuffer(r, &inStride);
 
@@ -108,10 +109,10 @@ void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf,
   }
 
   if (!r.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     r.width(), r.height(),
-                                     r.tl.x, r.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        r.width(), r.height(),
+                                        r.tl.x, r.tl.y,
+                                        width(), height()));
 
   if (stride == 0)
     stride = r.width();
@@ -125,9 +126,9 @@ void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf,
 void PixelBuffer::setSize(int width, int height)
 {
   if ((width < 0) || (width > maxPixelBufferWidth))
-    throw rfb::Exception(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
+    throw std::out_of_range(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
   if ((height < 0) || (height > maxPixelBufferHeight))
-    throw rfb::Exception(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
+    throw std::out_of_range(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
 
   width_ = width;
   height_ = height;
@@ -156,10 +157,10 @@ void ModifiablePixelBuffer::fillRect(const Rect& r, const void* pix)
   int w, h, b;
 
   if (!r.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     r.width(), r.height(),
-                                     r.tl.x, r.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        r.width(), r.height(),
+                                        r.tl.x, r.tl.y,
+                                        width(), height()));
 
   w = r.width();
   h = r.height();
@@ -208,10 +209,10 @@ void ModifiablePixelBuffer::imageRect(const Rect& r,
   uint8_t* end;
 
   if (!r.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     r.width(), r.height(),
-                                     r.tl.x, r.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        r.width(), r.height(),
+                                        r.tl.x, r.tl.y,
+                                        width(), height()));
 
   bytesPerPixel = getPF().bpp/8;
 
@@ -248,17 +249,17 @@ void ModifiablePixelBuffer::copyRect(const Rect &rect,
 
   drect = rect;
   if (!drect.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     drect.width(), drect.height(),
-                                     drect.tl.x, drect.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        drect.width(), drect.height(),
+                                        drect.tl.x, drect.tl.y,
+                                        width(), height()));
 
   srect = drect.translate(move_by_delta.negate());
   if (!srect.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     srect.width(), srect.height(),
-                                     srect.tl.x, srect.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        srect.width(), srect.height(),
+                                        srect.tl.x, srect.tl.y,
+                                        width(), height()));
 
   bytesPerPixel = format.bpp/8;
 
@@ -311,10 +312,10 @@ void ModifiablePixelBuffer::imageRect(const PixelFormat& pf, const Rect &dest,
   int dstStride;
 
   if (!dest.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     dest.width(), dest.height(),
-                                     dest.tl.x, dest.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        dest.width(), dest.height(),
+                                        dest.tl.x, dest.tl.y,
+                                        width(), height()));
 
   if (stride == 0)
     stride = dest.width();
@@ -341,10 +342,10 @@ FullFramePixelBuffer::~FullFramePixelBuffer() {}
 uint8_t* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride_)
 {
   if (!r.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     r.width(), r.height(),
-                                     r.tl.x, r.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        r.width(), r.height(),
+                                        r.tl.x, r.tl.y,
+                                        width(), height()));
 
   *stride_ = stride;
   return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
@@ -357,10 +358,10 @@ void FullFramePixelBuffer::commitBufferRW(const Rect& /*r*/)
 const uint8_t* FullFramePixelBuffer::getBuffer(const Rect& r, int* stride_) const
 {
   if (!r.enclosed_by(getRect()))
-    throw rfb::Exception(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
-                                     r.width(), r.height(),
-                                     r.tl.x, r.tl.y,
-                                     width(), height()));
+    throw std::out_of_range(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
+                                        r.width(), r.height(),
+                                        r.tl.x, r.tl.y,
+                                        width(), height()));
 
   *stride_ = stride;
   return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
@@ -370,13 +371,13 @@ void FullFramePixelBuffer::setBuffer(int width, int height,
                                      uint8_t* data_, int stride_)
 {
   if ((width < 0) || (width > maxPixelBufferWidth))
-    throw rfb::Exception(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
+    throw std::out_of_range(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
   if ((height < 0) || (height > maxPixelBufferHeight))
-    throw rfb::Exception(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
+    throw std::out_of_range(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
   if ((stride_ < 0) || (stride_ > maxPixelBufferStride) || (stride_ < width))
-    throw rfb::Exception(rfb::format("Invalid PixelBuffer stride of %d pixels requested", stride_));
+    throw std::invalid_argument(rfb::format("Invalid PixelBuffer stride of %d pixels requested", stride_));
   if ((width != 0) && (height != 0) && (data_ == nullptr))
-    throw rfb::Exception(rfb::format("PixelBuffer requested without a valid memory area"));
+    throw std::logic_error(rfb::format("PixelBuffer requested without a valid memory area"));
 
   ModifiablePixelBuffer::setSize(width, height);
   stride = stride_;
@@ -386,7 +387,7 @@ void FullFramePixelBuffer::setBuffer(int width, int height,
 void FullFramePixelBuffer::setSize(int /*w*/, int /*h*/)
 {
   // setBuffer() should be used
-  throw rfb::Exception("Invalid call to FullFramePixelBuffer::setSize()");
+  throw std::logic_error("Invalid call to FullFramePixelBuffer::setSize()");
 }
 
 // -=- Managed pixel buffer class
index b90fc206c1d25b4c7d806a21623851b4d33f24c1..f883cbf5513e63ad726581c643987113edd7719c 100644 (file)
@@ -86,7 +86,7 @@ PixelFormat::PixelFormat(int b, int d, bool e, bool t,
     redShift(rs), greenShift(gs), blueShift(bs)
 {
   if (!isSane())
-    throw Exception("invalid pixel format");
+    throw std::invalid_argument("invalid pixel format");
 
   updateState();
 }
index c43ed493dd95136b8ac41d2f844f8749c6193387..cf9dde056b99f0519902fc7b91b975f1d14d8a19 100644 (file)
@@ -95,14 +95,14 @@ bool SConnection::processMsg()
   case RFBSTATE_INITIALISATION:   return processInitMsg();         break;
   case RFBSTATE_NORMAL:           return reader_->readMsg();       break;
   case RFBSTATE_QUERYING:
-    throw Exception("SConnection::processMsg: bogus data from client while "
-                    "querying");
+    throw std::logic_error("SConnection::processMsg: bogus data from "
+                           "client while querying");
   case RFBSTATE_CLOSING:
-    throw Exception("SConnection::processMsg: called while closing");
+    throw std::logic_error("SConnection::processMsg: called while closing");
   case RFBSTATE_UNINITIALISED:
-    throw Exception("SConnection::processMsg: not initialised yet?");
+    throw std::logic_error("SConnection::processMsg: not initialised yet?");
   default:
-    throw Exception("SConnection::processMsg: invalid state");
+    throw std::logic_error("SConnection::processMsg: invalid state");
   }
 }
 
@@ -336,7 +336,7 @@ void SConnection::setAccessRights(AccessRights ar)
 bool SConnection::accessCheck(AccessRights ar) const
 {
   if (state_ < RFBSTATE_QUERYING)
-    throw Exception("SConnection::accessCheck: invalid state");
+    throw std::logic_error("SConnection::accessCheck: invalid state");
 
   return (accessRights & ar) == ar;
 }
@@ -449,7 +449,7 @@ void SConnection::queryConnection(const char* /*userName*/)
 void SConnection::approveConnection(bool accept, const char* reason)
 {
   if (state_ != RFBSTATE_QUERYING)
-    throw Exception("SConnection::approveConnection: invalid state");
+    throw std::logic_error("SConnection::approveConnection: invalid state");
 
   if (!client.beforeVersion(3,8) || ssecurity->getType() != secTypeNone) {
     if (accept) {
index 0c03b51dc18751530f6c471363752d69d52c92a3..f525d25a2495353aaf3fb782c0f9d16ece51a80c 100644 (file)
@@ -31,7 +31,6 @@
 #include <rfb/msgTypes.h>
 #include <rfb/fenceTypes.h>
 #include <rfb/clipboardTypes.h>
-#include <rfb/Exception.h>
 #include <rfb/ClientParams.h>
 #include <rfb/UpdateTracker.h>
 #include <rfb/Encoder.h>
@@ -94,7 +93,7 @@ void SMsgWriter::writeBell()
 void SMsgWriter::writeServerCutText(const char* str)
 {
   if (strchr(str, '\r') != nullptr)
-    throw Exception("Invalid carriage return in clipboard data");
+    throw std::invalid_argument("Invalid carriage return in clipboard data");
 
   std::string latin1(utf8ToLatin1(str));
 
@@ -111,7 +110,7 @@ void SMsgWriter::writeClipboardCaps(uint32_t caps,
   size_t i, count;
 
   if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
-    throw Exception("Client does not support extended clipboard");
+    throw std::logic_error("Client does not support extended clipboard");
 
   count = 0;
   for (i = 0;i < 16;i++) {
@@ -137,9 +136,9 @@ void SMsgWriter::writeClipboardCaps(uint32_t caps,
 void SMsgWriter::writeClipboardRequest(uint32_t flags)
 {
   if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
-    throw Exception("Client does not support extended clipboard");
+    throw std::logic_error("Client does not support extended clipboard");
   if (!(client->clipboardFlags() & clipboardRequest))
-    throw Exception("Client does not support clipboard \"request\" action");
+    throw std::logic_error("Client does not support clipboard \"request\" action");
 
   startMsg(msgTypeServerCutText);
   os->pad(3);
@@ -151,9 +150,9 @@ void SMsgWriter::writeClipboardRequest(uint32_t flags)
 void SMsgWriter::writeClipboardPeek(uint32_t flags)
 {
   if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
-    throw Exception("Client does not support extended clipboard");
+    throw std::logic_error("Client does not support extended clipboard");
   if (!(client->clipboardFlags() & clipboardPeek))
-    throw Exception("Client does not support clipboard \"peek\" action");
+    throw std::logic_error("Client does not support clipboard \"peek\" action");
 
   startMsg(msgTypeServerCutText);
   os->pad(3);
@@ -165,9 +164,9 @@ void SMsgWriter::writeClipboardPeek(uint32_t flags)
 void SMsgWriter::writeClipboardNotify(uint32_t flags)
 {
   if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
-    throw Exception("Client does not support extended clipboard");
+    throw std::logic_error("Client does not support extended clipboard");
   if (!(client->clipboardFlags() & clipboardNotify))
-    throw Exception("Client does not support clipboard \"notify\" action");
+    throw std::logic_error("Client does not support clipboard \"notify\" action");
 
   startMsg(msgTypeServerCutText);
   os->pad(3);
@@ -186,9 +185,9 @@ void SMsgWriter::writeClipboardProvide(uint32_t flags,
   int i, count;
 
   if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
-    throw Exception("Client does not support extended clipboard");
+    throw std::logic_error("Client does not support extended clipboard");
   if (!(client->clipboardFlags() & clipboardProvide))
-    throw Exception("Client does not support clipboard \"provide\" action");
+    throw std::logic_error("Client does not support clipboard \"provide\" action");
 
   zos.setUnderlying(&mos);
 
@@ -215,11 +214,11 @@ void SMsgWriter::writeFence(uint32_t flags, unsigned len,
                             const uint8_t data[])
 {
   if (!client->supportsEncoding(pseudoEncodingFence))
-    throw Exception("Client does not support fences");
+    throw std::logic_error("Client does not support fences");
   if (len > 64)
-    throw Exception("Too large fence payload");
+    throw std::out_of_range("Too large fence payload");
   if ((flags & ~fenceFlagsSupported) != 0)
-    throw Exception("Unknown fence flags");
+    throw std::invalid_argument("Unknown fence flags");
 
   startMsg(msgTypeServerFence);
   os->pad(3);
@@ -237,7 +236,7 @@ void SMsgWriter::writeFence(uint32_t flags, unsigned len,
 void SMsgWriter::writeEndOfContinuousUpdates()
 {
   if (!client->supportsEncoding(pseudoEncodingContinuousUpdates))
-    throw Exception("Client does not support continuous updates");
+    throw std::logic_error("Client does not support continuous updates");
 
   startMsg(msgTypeEndOfContinuousUpdates);
   endMsg();
@@ -249,7 +248,7 @@ void SMsgWriter::writeDesktopSize(uint16_t reason, uint16_t result)
 
   if (!client->supportsEncoding(pseudoEncodingDesktopSize) &&
       !client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
-    throw Exception("Client does not support desktop size changes");
+    throw std::logic_error("Client does not support desktop size changes");
 
   msg.reason = reason;
   msg.result = result;
@@ -260,7 +259,7 @@ void SMsgWriter::writeDesktopSize(uint16_t reason, uint16_t result)
 void SMsgWriter::writeSetDesktopName()
 {
   if (!client->supportsEncoding(pseudoEncodingDesktopName))
-    throw Exception("Client does not support desktop name changes");
+    throw std::logic_error("Client does not support desktop name changes");
 
   needSetDesktopName = true;
 }
@@ -271,7 +270,7 @@ void SMsgWriter::writeCursor()
       !client->supportsEncoding(pseudoEncodingXCursor) &&
       !client->supportsEncoding(pseudoEncodingCursorWithAlpha) &&
       !client->supportsEncoding(pseudoEncodingVMwareCursor))
-    throw Exception("Client does not support local cursor");
+    throw std::logic_error("Client does not support local cursor");
 
   needCursor = true;
 }
@@ -279,7 +278,7 @@ void SMsgWriter::writeCursor()
 void SMsgWriter::writeCursorPos()
 {
   if (!client->supportsEncoding(pseudoEncodingVMwareCursorPosition))
-    throw Exception("Client does not support cursor position");
+    throw std::logic_error("Client does not support cursor position");
 
   needCursorPos = true;
 }
@@ -288,9 +287,9 @@ void SMsgWriter::writeLEDState()
 {
   if (!client->supportsEncoding(pseudoEncodingLEDState) &&
       !client->supportsEncoding(pseudoEncodingVMwareLEDState))
-    throw Exception("Client does not support LED state");
+    throw std::logic_error("Client does not support LED state");
   if (client->ledState() == ledUnknown)
-    throw Exception("Server has not specified LED state");
+    throw std::logic_error("Server has not specified LED state");
 
   needLEDState = true;
 }
@@ -298,7 +297,7 @@ void SMsgWriter::writeLEDState()
 void SMsgWriter::writeQEMUKeyEvent()
 {
   if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
-    throw Exception("Client does not support QEMU key events");
+    throw std::logic_error("Client does not support QEMU key events");
 
   needQEMUKeyEvent = true;
 }
@@ -379,8 +378,8 @@ void SMsgWriter::writeFramebufferUpdateStart(int nRects)
 void SMsgWriter::writeFramebufferUpdateEnd()
 {
   if (nRectsInUpdate != nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeFramebufferUpdateEnd: "
-                    "nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeFramebufferUpdateEnd: "
+                           "nRects out of sync");
 
   if (nRectsInHeader == 0) {
     // Send last rect. marker
@@ -405,7 +404,7 @@ void SMsgWriter::writeCopyRect(const Rect& r, int srcX, int srcY)
 void SMsgWriter::startRect(const Rect& r, int encoding)
 {
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::startRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::startRect: nRects out of sync");
 
   os->writeS16(r.tl.x);
   os->writeS16(r.tl.y);
@@ -470,7 +469,7 @@ void SMsgWriter::writePseudoRects()
                           cursor.hotspot().x, cursor.hotspot().y,
                           bitmap.data(), mask.data());
     } else {
-      throw Exception("Client does not support local cursor");
+      throw std::logic_error("Client does not support local cursor");
     }
 
     needCursor = false;
@@ -482,7 +481,7 @@ void SMsgWriter::writePseudoRects()
     if (client->supportsEncoding(pseudoEncodingVMwareCursorPosition)) {
       writeSetVMwareCursorPositionRect(cursorPos.x, cursorPos.y);
     } else {
-      throw Exception("Client does not support cursor position");
+      throw std::logic_error("Client does not support cursor position");
     }
 
     needCursorPos = false;
@@ -519,7 +518,7 @@ void SMsgWriter::writeNoDataRects()
       // more after this
       writeSetDesktopSizeRect(client->width(), client->height());
     } else {
-      throw Exception("Client does not support desktop size changes");
+      throw std::logic_error("Client does not support desktop size changes");
     }
 
     extendedDesktopSizeMsgs.clear();
@@ -529,9 +528,9 @@ void SMsgWriter::writeNoDataRects()
 void SMsgWriter::writeSetDesktopSizeRect(int width, int height)
 {
   if (!client->supportsEncoding(pseudoEncodingDesktopSize))
-    throw Exception("Client does not support desktop resize");
+    throw std::logic_error("Client does not support desktop resize");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
 
   os->writeS16(0);
   os->writeS16(0);
@@ -549,9 +548,9 @@ void SMsgWriter::writeExtendedDesktopSizeRect(uint16_t reason,
   ScreenSet::const_iterator si;
 
   if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
-    throw Exception("Client does not support extended desktop resize");
+    throw std::logic_error("Client does not support extended desktop resize");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
 
   os->writeU16(reason);
   os->writeU16(result);
@@ -575,9 +574,9 @@ void SMsgWriter::writeExtendedDesktopSizeRect(uint16_t reason,
 void SMsgWriter::writeSetDesktopNameRect(const char *name)
 {
   if (!client->supportsEncoding(pseudoEncodingDesktopName))
-    throw Exception("Client does not support desktop rename");
+    throw std::logic_error("Client does not support desktop rename");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
 
   os->writeS16(0);
   os->writeS16(0);
@@ -594,9 +593,9 @@ void SMsgWriter::writeSetCursorRect(int width, int height,
                                     const uint8_t* mask)
 {
   if (!client->supportsEncoding(pseudoEncodingCursor))
-    throw Exception("Client does not support local cursors");
+    throw std::logic_error("Client does not support local cursors");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeSetCursorRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeSetCursorRect: nRects out of sync");
 
   os->writeS16(hotspotX);
   os->writeS16(hotspotY);
@@ -613,9 +612,9 @@ void SMsgWriter::writeSetXCursorRect(int width, int height,
                                      const uint8_t* mask)
 {
   if (!client->supportsEncoding(pseudoEncodingXCursor))
-    throw Exception("Client does not support local cursors");
+    throw std::logic_error("Client does not support local cursors");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeSetXCursorRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeSetXCursorRect: nRects out of sync");
 
   os->writeS16(hotspotX);
   os->writeS16(hotspotY);
@@ -639,9 +638,9 @@ void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height,
                                              const uint8_t* data)
 {
   if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
-    throw Exception("Client does not support local cursors");
+    throw std::logic_error("Client does not support local cursors");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
 
   os->writeS16(hotspotX);
   os->writeS16(hotspotY);
@@ -667,9 +666,9 @@ void SMsgWriter::writeSetVMwareCursorRect(int width, int height,
                                           const uint8_t* data)
 {
   if (!client->supportsEncoding(pseudoEncodingVMwareCursor))
-    throw Exception("Client does not support local cursors");
+    throw std::logic_error("Client does not support local cursors");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
 
   os->writeS16(hotspotX);
   os->writeS16(hotspotY);
@@ -687,9 +686,9 @@ void SMsgWriter::writeSetVMwareCursorRect(int width, int height,
 void SMsgWriter::writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY)
 {
   if (!client->supportsEncoding(pseudoEncodingVMwareCursorPosition))
-    throw Exception("Client does not support cursor position");
+    throw std::logic_error("Client does not support cursor position");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
 
   os->writeS16(hotspotX);
   os->writeS16(hotspotY);
@@ -702,11 +701,11 @@ void SMsgWriter::writeLEDStateRect(uint8_t state)
 {
   if (!client->supportsEncoding(pseudoEncodingLEDState) &&
       !client->supportsEncoding(pseudoEncodingVMwareLEDState))
-    throw Exception("Client does not support LED state updates");
+    throw std::logic_error("Client does not support LED state updates");
   if (client->ledState() == ledUnknown)
-    throw Exception("Server does not support LED state updates");
+    throw std::logic_error("Server does not support LED state updates");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeLEDStateRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeLEDStateRect: nRects out of sync");
 
   os->writeS16(0);
   os->writeS16(0);
@@ -724,9 +723,9 @@ void SMsgWriter::writeLEDStateRect(uint8_t state)
 void SMsgWriter::writeQEMUKeyEventRect()
 {
   if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
-    throw Exception("Client does not support QEMU extended key events");
+    throw std::logic_error("Client does not support QEMU extended key events");
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
-    throw Exception("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
+    throw std::logic_error("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
 
   os->writeS16(0);
   os->writeS16(0);
index e009de39e15881d84560f0b7fb97b6eb1cd1ca04..1115b7ff282d5f6e9e381548c2836f5bea489d9f 100644 (file)
@@ -87,7 +87,7 @@ bool SSecurityPlain::processMsg()
   char password[1024];
 
   if (!valid)
-    throw Exception("No password validator configured");
+    throw std::logic_error("No password validator configured");
 
   if (state == 0) {
     if (!is->hasData(8))
index 6dd700cef45c428818551c231f336b2b1ab42687..10e901fbb240f0ac8ab078287ffe917471773196 100644 (file)
@@ -161,7 +161,7 @@ void SSecurityRSAAES::loadPrivateKey()
   size_t size = ftell(file);
   if (size == 0 || size > MaxKeyFileSize) {
     fclose(file);
-    throw Exception("size of key file is zero or too big");
+    throw std::runtime_error("size of key file is zero or too big");
   }
   fseek(file, 0, SEEK_SET);
   std::vector<uint8_t> data(size);
@@ -184,7 +184,7 @@ void SSecurityRSAAES::loadPrivateKey()
     loadPKCS8Key(der.data(), der.size());
     return;
   }
-  throw Exception("failed to import key");
+  throw std::runtime_error("failed to import key");
 }
 
 void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size)
@@ -195,7 +195,7 @@ void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size)
   if (!rsa_keypair_from_der(&pub, &serverKey, 0, size, data)) {
     rsa_private_key_clear(&serverKey);
     rsa_public_key_clear(&pub);
-    throw Exception("failed to import key");
+    throw std::runtime_error("failed to import key");
   }
   serverKeyLength = serverKey.size * 8;
   serverKeyN = new uint8_t[serverKey.size];
@@ -235,7 +235,7 @@ void SSecurityRSAAES::loadPKCS8Key(const uint8_t* data, size_t size)
   loadPKCS1Key(i.data, i.length);
   return;
 failed:
-  throw Exception("failed to import key");
+  throw std::runtime_error("failed to import key");
 }
 
 bool SSecurityRSAAES::processMsg()
@@ -319,7 +319,7 @@ static void random_func(void* ctx, size_t length, uint8_t* dst)
 {
   rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
   if (!rs->hasData(length))
-    throw Exception("failed to encrypt random");
+    throw std::runtime_error("failed to encrypt random");
   rs->readBytes(dst, length);
 }
 
@@ -327,7 +327,7 @@ void SSecurityRSAAES::writeRandom()
 {
   rdr::OutStream* os = sc->getOutStream();
   if (!rs.hasData(keySize / 8))
-    throw Exception("failed to generate random");
+    throw std::runtime_error("failed to generate random");
   rs.readBytes(serverRandom, keySize / 8);
   mpz_t x;
   mpz_init(x);
@@ -341,7 +341,7 @@ void SSecurityRSAAES::writeRandom()
   }
   if (!res) {
     mpz_clear(x);
-    throw Exception("failed to encrypt random");
+    throw std::runtime_error("failed to encrypt random");
   }
   uint8_t* buffer = new uint8_t[clientKey.size];
   nettle_mpz_get_str_256(clientKey.size, buffer, x);
@@ -566,7 +566,7 @@ void SSecurityRSAAES::verifyUserPass()
   }
   delete valid;
 #else
-  throw Exception("No password validator configured");
+  throw std::logic_error("No password validator configured");
 #endif
 }
 
@@ -577,7 +577,7 @@ void SSecurityRSAAES::verifyPass()
   pg->getVncAuthPasswd(&passwd, &passwdReadOnly);
 
   if (passwd.empty())
-    throw Exception("No password configured");
+    throw std::runtime_error("No password configured");
 
   if (password == passwd) {
     accessRights = AccessDefault;
index 272c7ca1ecc880d2ea1286a773ca13dbc7bb5221..b0401840e3f00c60498320adb1b344689821b762 100644 (file)
@@ -83,7 +83,7 @@ bool SSecurityVncAuth::processMsg()
   if (!sentChallenge) {
     rdr::RandomStream rs;
     if (!rs.hasData(vncAuthChallengeSize))
-      throw Exception("Could not generate random data for VNC auth challenge");
+      throw std::runtime_error("Could not generate random data for VNC auth challenge");
     rs.readBytes(challenge, vncAuthChallengeSize);
     os->writeBytes(challenge, vncAuthChallengeSize);
     os->flush();
@@ -100,7 +100,7 @@ bool SSecurityVncAuth::processMsg()
   pg->getVncAuthPasswd(&passwd, &passwdReadOnly);
 
   if (passwd.empty())
-    throw Exception("No password configured");
+    throw std::runtime_error("No password configured");
 
   if (verifyResponse(passwd.c_str())) {
     accessRights = AccessDefault;
index 9cd3b90475b5d969cf635014d63e447558898300..878edde9405e3fdbc3850891feaf7145b84678fb 100644 (file)
@@ -27,7 +27,6 @@
 #include <rfb/CSecurityVeNCrypt.h>
 #include <rfb/CSecurityVncAuth.h>
 #include <rfb/CSecurityPlain.h>
-#include <rfb/Exception.h>
 #include <rfb/Security.h>
 #ifdef HAVE_GNUTLS
 #include <rfb/CSecurityTLS.h>
@@ -110,5 +109,5 @@ CSecurity* SecurityClient::GetCSecurity(CConnection* cc, uint32_t secType)
   }
 
 bail:
-  throw Exception("Security type not supported");
+  throw std::invalid_argument("Security type not supported");
 }
index b52977366ef44ec54fb01dc17568c2bc58f3d34f..d692f4fc93d42010d7af38e505f58d764a3d9239 100644 (file)
@@ -21,7 +21,6 @@
 #include <config.h>
 #endif
 
-#include <rfb/Exception.h>
 #include <rfb/Security.h>
 #include <rfb/SSecurityNone.h>
 #include <rfb/SSecurityStack.h>
@@ -90,6 +89,6 @@ SSecurity* SecurityServer::GetSSecurity(SConnection* sc, uint32_t secType)
   }
 
 bail:
-  throw Exception("Security type not supported");
+  throw std::invalid_argument("Security type not supported");
 }
 
index 2a8d3a8ea9484688c34544814fb34c27a83c9e15..df8ad40d3ab06a3182cfdd672e890976bf98f593 100644 (file)
@@ -22,7 +22,8 @@
 #include <config.h>
 #endif
 
-#include <rfb/Exception.h>
+#include <stdexcept>
+
 #include <rfb/ledStates.h>
 #include <rfb/ServerParams.h>
 #include <rfb/util.h>
@@ -60,7 +61,7 @@ void ServerParams::setDimensions(int width, int height)
 void ServerParams::setDimensions(int width, int height, const ScreenSet& layout)
 {
   if (!layout.validate(width, height))
-    throw Exception("Attempted to configure an invalid screen layout");
+    throw std::invalid_argument("Attempted to configure an invalid screen layout");
 
   width_ = width;
   height_ = height;
@@ -72,7 +73,7 @@ void ServerParams::setPF(const PixelFormat& pf)
   pf_ = pf;
 
   if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
-    throw Exception("setPF: not 8, 16 or 32 bpp?");
+    throw std::invalid_argument("setPF: not 8, 16 or 32 bpp?");
 }
 
 void ServerParams::setName(const char* name)
@@ -100,7 +101,7 @@ uint32_t ServerParams::clipboardSize(unsigned int format) const
       return clipSizes[i];
   }
 
-  throw Exception(rfb::format("Invalid clipboard format 0x%x", format));
+  throw std::invalid_argument(rfb::format("Invalid clipboard format 0x%x", format));
 }
 
 void ServerParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
index f1ea2958d71455d09e6fe5bc1b509e7b89927d89..c2f47476dbf593e2e8e7bb62de667fe281ef6fdd 100644 (file)
@@ -58,7 +58,6 @@
 #include <network/Socket.h>
 
 #include <rfb/ComparingUpdateTracker.h>
-#include <rfb/Exception.h>
 #include <rfb/KeyRemapper.h>
 #include <rfb/KeysymStr.h>
 #include <rfb/LogWriter.h>
@@ -224,7 +223,7 @@ void VNCServerST::processSocketReadEvent(network::Socket* sock)
       return;
     }
   }
-  throw rdr::Exception("invalid Socket in VNCServerST");
+  throw std::invalid_argument("invalid Socket in VNCServerST");
 }
 
 void VNCServerST::processSocketWriteEvent(network::Socket* sock)
@@ -237,7 +236,7 @@ void VNCServerST::processSocketWriteEvent(network::Socket* sock)
       return;
     }
   }
-  throw rdr::Exception("invalid Socket in VNCServerST");
+  throw std::invalid_argument("invalid Socket in VNCServerST");
 }
 
 void VNCServerST::blockUpdates()
@@ -284,13 +283,13 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
     screenLayout = ScreenSet();
 
     if (desktopStarted)
-      throw Exception("setPixelBuffer: null PixelBuffer when desktopStarted?");
+      throw std::logic_error("setPixelBuffer: null PixelBuffer when desktopStarted?");
 
     return;
   }
 
   if (!layout.validate(pb->width(), pb->height()))
-    throw Exception("setPixelBuffer: invalid screen layout");
+    throw std::invalid_argument("setPixelBuffer: invalid screen layout");
 
   screenLayout = layout;
 
@@ -342,9 +341,9 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_)
 void VNCServerST::setScreenLayout(const ScreenSet& layout)
 {
   if (!pb)
-    throw Exception("setScreenLayout: new screen layout without a PixelBuffer");
+    throw std::logic_error("setScreenLayout: new screen layout without a PixelBuffer");
   if (!layout.validate(pb->width(), pb->height()))
-    throw Exception("setScreenLayout: invalid screen layout");
+    throw std::invalid_argument("setScreenLayout: invalid screen layout");
 
   screenLayout = layout;
 
@@ -378,7 +377,7 @@ void VNCServerST::sendClipboardData(const char* data)
   std::list<VNCSConnectionST*>::iterator ci;
 
   if (strchr(data, '\r') != nullptr)
-    throw Exception("Invalid carriage return in clipboard data");
+    throw std::invalid_argument("Invalid carriage return in clipboard data");
 
   for (ci = clipboardRequestors.begin();
        ci != clipboardRequestors.end(); ++ci)
@@ -566,7 +565,7 @@ unsigned int VNCServerST::setDesktopSize(VNCSConnectionST* requester,
 
   // Sanity check
   if (screenLayout != layout)
-    throw Exception("Desktop configured a different screen layout than requested");
+    throw std::runtime_error("Desktop configured a different screen layout than requested");
 
   // Notify other clients
   for (ci = clients.begin(); ci != clients.end(); ++ci) {
@@ -727,7 +726,7 @@ void VNCServerST::startDesktop()
     slog.debug("starting desktop");
     desktop->start();
     if (!pb)
-      throw Exception("SDesktop::start() did not set a valid PixelBuffer");
+      throw std::logic_error("SDesktop::start() did not set a valid PixelBuffer");
     desktopStarted = true;
     // The tracker might have accumulated changes whilst we were
     // stopped, so flush those out
index 2afc151233d2b085174570593775cb0450860180..a88d2822973056d31c3da6959e55d635dfc3a667 100644 (file)
 #include <assert.h>
 #include <string.h>
 
+#include <stdexcept>
+
 extern "C" {
 #include <rfb/d3des.h>
 }
 
-#include <rdr/Exception.h>
 #include <rfb/obfuscate.h>
 
 static unsigned char d3desObfuscationKey[] = {23,82,107,6,35,78,88,7};
@@ -57,7 +58,7 @@ std::string rfb::deobfuscate(const uint8_t *data, size_t len)
   char buf[9];
 
   if (len != 8)
-    throw rdr::Exception("bad obfuscated password length");
+    throw std::invalid_argument("bad obfuscated password length");
 
   assert(data != nullptr);
 
index cc8b39d08a57bb2152169531fd7f1580b15d5311..41a93b3a56a0289689ce1a37f11e9cc18a1a6c20 100644 (file)
@@ -110,7 +110,7 @@ void DummyOutStream::overrun(size_t needed)
 {
   flush();
   if (avail() < needed)
-    throw rdr::Exception("Insufficient dummy output buffer");
+    throw std::out_of_range("Insufficient dummy output buffer");
 }
 
 CConn::CConn(const char *filename)
@@ -202,7 +202,7 @@ static struct stats runTest(const char *fn)
 
   try {
     cc = new CConn(fn);
-  } catch (rdr::Exception& e) {
+  } catch (std::exception& e) {
     fprintf(stderr, "Failed to open rfb file: %s\n", e.what());
     exit(1);
   }
@@ -211,7 +211,7 @@ static struct stats runTest(const char *fn)
     while (true)
       cc->processMsg();
   } catch (rdr::EndOfStream& e) {
-  } catch (rdr::Exception& e) {
+  } catch (std::exception& e) {
     fprintf(stderr, "Failed to run rfb file: %s\n", e.what());
     exit(1);
   }
index 63794340f18c5b2c2c21974b473c354edc00eefa..9c7c77fda91ccc25562fee90d9fa0bdced02bfb5 100644 (file)
@@ -171,7 +171,7 @@ void DummyOutStream::overrun(size_t needed)
 {
   flush();
   if (avail() < needed)
-    throw rdr::Exception("Insufficient dummy output buffer");
+    throw std::out_of_range("Insufficient dummy output buffer");
 }
 
 CConn::CConn(const char *filename)
index 9d86fb9ff1d161eb361a3a8db003d3a14264b1bb..54e68ccf0deb1a89fc90f9c7ebea5ae12f4984ba 100644 (file)
@@ -22,8 +22,9 @@
 
 #include <stdio.h>
 
+#include <stdexcept>
+
 #include <rfb/PixelFormat.h>
-#include <rfb/Exception.h>
 
 static void doTest(bool should_fail, int b, int d, bool e, bool t,
                    int rm, int gm, int bm, int rs, int gs, int bs)
index 3a22fd07dbc32b2463396e44dfb2de9a7f1a8297..c663ffaeca869de3a53817df443449538f75ee99 100644 (file)
@@ -28,6 +28,8 @@
 #ifndef __TXDIALOG_H__
 #define __TXDIALOG_H__
 
+#include <rdr/Exception.h>
+
 #include "TXWindow.h"
 #include <errno.h>
 
index 9251e37129b08f7515c2bc92d4bcfce390db0d62..b4e795efcd1c9a241968ce9421d14a05e4f333aa 100644 (file)
@@ -31,7 +31,6 @@
 #include <network/Socket.h>
 
 #include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
 
 #include <x0vncserver/XDesktop.h>
 
@@ -98,7 +97,7 @@ XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
   if (!XkbQueryExtension(dpy, &xkbOpcode, &xkbEventBase,
                          &xkbErrorBase, &major, &minor)) {
     vlog.error("XKEYBOARD extension not present");
-    throw Exception("XKEYBOARD extension not present");
+    throw std::runtime_error("XKEYBOARD extension not present");
   }
 
   XkbSelectEvents(dpy, XkbUseCoreKbd, XkbIndicatorStateNotifyMask,
index ab4b28d379f6e7c5c3eaebff767d506ffcf29ffe..e56e0db017f25bfa16f903f5775defdec785e3ca 100644 (file)
@@ -250,7 +250,7 @@ void vncExtensionInit(void)
         }
 
         if (!inetd && listeners.empty())
-          throw rdr::Exception("No path or port configured for incoming connections");
+          throw std::runtime_error("No path or port configured for incoming connections");
 
         PixelFormat pf = vncGetPixelFormat(scr);
 
index fef8b3d90ea9f3d5164f74bb0953bd9eb44fff56..8eeed56810ddb171b3dc607e467eb8f30f9485c3 100644 (file)
@@ -54,7 +54,7 @@
 
 #include <assert.h>
 
-#include <rfb/Exception.h>
+#include <stdexcept>
 
 #include "parameters.h"
 #include "i18n.h"
@@ -223,7 +223,7 @@ void EmulateMB::filterPointerEvent(const rfb::Point& pos, uint8_t buttonMask)
     btstate |= 0x2;
 
   if ((state > 10) || (state < 0))
-    throw rfb::Exception(_("Invalid state for 3 button emulation"));
+    throw std::runtime_error(_("Invalid state for 3 button emulation"));
 
   action1 = stateTab[state][btstate][0];
 
@@ -286,7 +286,7 @@ void EmulateMB::handleTimeout(rfb::Timer *t)
     return;
 
   if ((state > 10) || (state < 0))
-    throw rfb::Exception(_("Invalid state for 3 button emulation"));
+    throw std::runtime_error(_("Invalid state for 3 button emulation"));
 
   // Timeout shouldn't trigger when there's no timeout action
   assert(stateTab[state][4][2] >= 0);
index bcb4cb231e342e02a95c1c200e9f157dcee11138..0f152e114c760606ebb6419a57aedd1f404b7952 100644 (file)
 #include <sys/shm.h>
 #endif
 
+#include <stdexcept>
+
 #include <FL/Fl.H>
 #include <FL/x.H>
 
 #include <rfb/LogWriter.h>
-#include <rdr/Exception.h>
 
 #include "PlatformPixelBuffer.h"
 
@@ -52,11 +53,11 @@ PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) :
     xim = XCreateImage(fl_display, (Visual*)CopyFromParent, 32,
                        ZPixmap, 0, nullptr, width, height, 32, 0);
     if (!xim)
-      throw rdr::Exception("XCreateImage");
+      throw std::runtime_error("XCreateImage");
 
     xim->data = (char*)malloc(xim->bytes_per_line * xim->height);
     if (!xim->data)
-      throw rdr::Exception("malloc");
+      throw std::bad_alloc();
 
     vlog.debug("Using standard XImage");
   }
index 3de4e388120b029c2a1396c461ed5a2a6b7a2368..d4ec2006f353acb2a4721ebfd4010268a832d5f2 100644 (file)
@@ -346,7 +346,7 @@ void ServerDialog::loadServerHistory()
 
   const char* stateDir = os::getvncstatedir();
   if (stateDir == nullptr)
-    throw Exception(_("Could not determine VNC state directory path"));
+    throw std::runtime_error(_("Could not determine VNC state directory path"));
 
   char filepath[PATH_MAX];
   snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY);
@@ -382,8 +382,11 @@ void ServerDialog::loadServerHistory()
 
     if (len == (sizeof(line) - 1)) {
       fclose(f);
-      throw Exception(format(_("Failed to read line %d in file %s: %s"),
-                             lineNr, filepath, _("Line too long")));
+      throw std::runtime_error(format("%s: %s",
+                                      format(_("Failed to read line %d "
+                                               "in file %s"),
+                                             lineNr, filepath).c_str(),
+                                      _("Line too long")));
     }
 
     if ((len > 0) && (line[len-1] == '\n')) {
@@ -422,7 +425,7 @@ void ServerDialog::saveServerHistory()
 
   const char* stateDir = os::getvncstatedir();
   if (stateDir == nullptr)
-    throw Exception(_("Could not determine VNC state directory path"));
+    throw std::runtime_error(_("Could not determine VNC state directory path"));
 
   char filepath[PATH_MAX];
   snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY);
index 673f37e995c5caa5f67883f900946fb44ac230f6..dcc3d8572710864f87c31b9bbf9afa174e0fff08 100644 (file)
 
 #include <assert.h>
 
+#include <stdexcept>
+
 #include <ApplicationServices/ApplicationServices.h>
 
 #include <FL/Fl_RGB_Image.H>
 #include <FL/Fl_Window.H>
 #include <FL/x.H>
 
-#include <rdr/Exception.h>
-
 #include "cocoa.h"
 #include "Surface.h"
 
@@ -47,7 +47,7 @@ static CGImageRef create_image(CGColorSpaceRef lut,
   provider = CGDataProviderCreateWithData(nullptr, data,
                                           w * h * 4, nullptr);
   if (!provider)
-    throw rdr::Exception("CGDataProviderCreateWithData");
+    throw std::runtime_error("CGDataProviderCreateWithData");
 
   // FIXME: This causes a performance hit, but is necessary to avoid
   //        artifacts in the edges of the window
@@ -62,7 +62,7 @@ static CGImageRef create_image(CGColorSpaceRef lut,
                         kCGRenderingIntentDefault);
   CGDataProviderRelease(provider);
   if (!image)
-    throw rdr::Exception("CGImageCreate");
+    throw std::runtime_error("CGImageCreate");
 
   return image;
 }
@@ -85,7 +85,7 @@ static void render(CGContextRef gc, CGColorSpaceRef lut,
 
   subimage = CGImageCreateWithImageInRect(image, rect);
   if (!subimage)
-    throw rdr::Exception("CGImageCreateImageWithImageInRect");
+    throw std::runtime_error("CGImageCreateImageWithImageInRect");
 
   CGContextSaveGState(gc);
 
@@ -112,7 +112,7 @@ static CGContextRef make_bitmap(int width, int height, unsigned char* data)
   bitmap = CGBitmapContextCreate(data, width, height, 8, width*4, srgb,
                                  kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
   if (!bitmap)
-    throw rdr::Exception("CGBitmapContextCreate");
+    throw std::runtime_error("CGBitmapContextCreate");
 
   return bitmap;
 }
index d27fcd262e0fb5e1737f9b6329704b0d5052506f..e73985f054186f486a625e00fae72628cded77ca 100644 (file)
 #include <assert.h>
 #include <stdlib.h>
 
+#include <stdexcept>
+
 #include <FL/Fl_RGB_Image.H>
 #include <FL/x.H>
 
-#include <rdr/Exception.h>
-
 #include "Surface.h"
 
 void Surface::clear(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
@@ -156,7 +156,7 @@ void Surface::alloc()
                              &templ, 0);
 
   if (!format)
-    throw rdr::Exception("XRenderFindFormat");
+    throw std::runtime_error("XRenderFindFormat");
 
   picture = XRenderCreatePicture(fl_display, pixmap, format, 0, nullptr);
 
@@ -185,11 +185,11 @@ void Surface::update(const Fl_RGB_Image* image)
                      ZPixmap, 0, nullptr, width(), height(),
                      32, 0);
   if (!img)
-    throw rdr::Exception("XCreateImage");
+    throw std::runtime_error("XCreateImage");
 
   img->data = (char*)malloc(img->bytes_per_line * img->height);
   if (!img->data)
-    throw rdr::Exception("malloc");
+    throw std::bad_alloc();
 
   // Convert data and pre-multiply alpha
   in = (const unsigned char*)image->data()[0];
index 42a5d002fe0ae995ed500a4bedfd8d30a9ce29ef..52fde49c7cc6b8180b157e89323f83b37eff6b6b 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <rfb/CMsgWriter.h>
 #include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
 #include <rfb/KeysymStr.h>
 #include <rfb/ledStates.h>
 #include <rfb/util.h>
@@ -130,11 +129,11 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& /*serverPF*/, CConn* cc
 
   xkb = XkbGetMap(fl_display, 0, XkbUseCoreKbd);
   if (!xkb)
-    throw rfb::Exception("XkbGetMap");
+    throw std::runtime_error("XkbGetMap");
 
   status = XkbGetNames(fl_display, XkbKeyNamesMask, xkb);
   if (status != Success)
-    throw rfb::Exception("XkbGetNames");
+    throw std::runtime_error("XkbGetNames");
 
   memset(code_map_keycode_to_qnum, 0, sizeof(code_map_keycode_to_qnum));
   for (KeyCode keycode = xkb->min_key_code;
index e21768f926cb611f98abc09d2d6125aeaffc38d7..2be27ede9ad96fdb8998650b08d685a9c77e7c96 100644 (file)
 
 #include <math.h>
 
+#include <stdexcept>
+
 #define XK_MISCELLANY
 #include <rfb/keysymdef.h>
-#include <rfb/Exception.h>
 #include <rfb/LogWriter.h>
 
 #include "i18n.h"
@@ -44,7 +45,7 @@ Win32TouchHandler::Win32TouchHandler(HWND hWnd_) :
   // If window is registered as touch we can not receive gestures,
   // this should not happen
   if (IsTouchWindow(hWnd, nullptr))
-    throw rfb::Exception(_("Window is registered for touch instead of gestures"));
+    throw std::runtime_error(_("Window is registered for touch instead of gestures"));
 
   // We will not receive any touch/gesture events if this service
   // isn't running - Logging is enough
index f1b5a8528a5e39b038dfe38597cbf26060916418..de7289876dbc2bbe890850ceef003a52048ce55c 100644 (file)
@@ -305,16 +305,16 @@ static void setKeyString(const char *_name, const char *_value, HKEY* hKey) {
   wchar_t name[buffersize];
   unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
   if (size >= buffersize)
-    throw Exception(_("The name of the parameter is too large"));
+    throw std::invalid_argument(_("The name of the parameter is too large"));
 
   char encodingBuffer[buffersize];
   if (!encodeValue(_value, encodingBuffer, buffersize))
-    throw Exception(_("The parameter is too large"));
+    throw std::invalid_argument(_("The parameter is too large"));
 
   wchar_t value[buffersize];
   size = fl_utf8towc(encodingBuffer, strlen(encodingBuffer)+1, value, buffersize);
   if (size >= buffersize)
-    throw Exception(_("The parameter is too large"));
+    throw std::invalid_argument(_("The parameter is too large"));
 
   LONG res = RegSetValueExW(*hKey, name, 0, REG_SZ, (BYTE*)&value, (wcslen(value)+1)*2);
   if (res != ERROR_SUCCESS)
@@ -330,7 +330,7 @@ static void setKeyInt(const char *_name, const int _value, HKEY* hKey) {
 
   unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
   if (size >= buffersize)
-    throw Exception(_("The name of the parameter is too large"));
+    throw std::out_of_range(_("The name of the parameter is too large"));
 
   LONG res = RegSetValueExW(*hKey, name, 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD));
   if (res != ERROR_SUCCESS)
@@ -347,7 +347,7 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h
 
   unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
   if (size >= buffersize)
-    throw Exception(_("The name of the parameter is too large"));
+    throw std::out_of_range(_("The name of the parameter is too large"));
 
   value = new WCHAR[destSize];
   valuesize = destSize;
@@ -365,14 +365,14 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h
   delete [] value;
   if (size >= destSize) {
     delete [] utf8val;
-    throw Exception(_("The parameter is too large"));
+    throw std::out_of_range(_("The parameter is too large"));
   }
 
   bool ret = decodeValue(utf8val, dest, destSize);
   delete [] utf8val;
 
   if (!ret)
-    throw Exception(_("Invalid format or too large value"));
+    throw std::invalid_argument(_("Invalid format or too large value"));
 
   return true;
 }
@@ -387,7 +387,7 @@ static bool getKeyInt(const char* _name, int* dest, HKEY* hKey) {
 
   unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
   if (size >= buffersize)
-    throw Exception(_("The name of the parameter is too large"));
+    throw std::out_of_range(_("The name of the parameter is too large"));
 
   LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)&value, &dwordsize);
   if (res != ERROR_SUCCESS){
@@ -407,7 +407,7 @@ static void removeValue(const char* _name, HKEY* hKey) {
 
   unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
   if (size >= buffersize)
-    throw Exception(_("The name of the parameter is too large"));
+    throw std::out_of_range(_("The name of the parameter is too large"));
 
   LONG res = RegDeleteValueW(*hKey, name);
   if (res != ERROR_SUCCESS) {
@@ -465,8 +465,8 @@ static void saveToReg(const char* servername) {
     setKeyString("ServerName", servername, &hKey);
   } catch (std::exception& e) {
     RegCloseKey(hKey);
-    throw Exception(format(_("Failed to save \"%s\": %s"),
-                           "ServerName", e.what()));
+    throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+                                    "ServerName", e.what()));
   }
 
   for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
@@ -478,12 +478,13 @@ static void saveToReg(const char* servername) {
       } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != nullptr) {
         setKeyInt(parameterArray[i]->getName(), (int)*(BoolParameter*)parameterArray[i], &hKey);
       } else {
-        throw Exception(_("Unknown parameter type"));
+        throw std::logic_error(_("Unknown parameter type"));
       }
     } catch (std::exception& e) {
       RegCloseKey(hKey);
-      throw Exception(format(_("Failed to save \"%s\": %s"),
-                             parameterArray[i]->getName(), e.what()));
+      throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+                                      parameterArray[i]->getName(),
+                                      e.what()));
     }
   }
 
@@ -495,9 +496,9 @@ static void saveToReg(const char* servername) {
       removeValue(readOnlyParameterArray[i]->getName(), &hKey);
     } catch (std::exception& e) {
       RegCloseKey(hKey);
-      throw Exception(format(_("Failed to remove \"%s\": %s"),
-                             readOnlyParameterArray[i]->getName(),
-                             e.what()));
+      throw std::runtime_error(format(_("Failed to remove \"%s\": %s"),
+                                      readOnlyParameterArray[i]->getName(),
+                                      e.what()));
     }
   }
 
@@ -570,7 +571,7 @@ static void getParametersFromReg(VoidParameter* parameters[],
         if (getKeyInt(parameters[i]->getName(), &intValue, hKey))
           ((BoolParameter*)parameters[i])->setParam(intValue);
       } else {
-        throw Exception(_("Unknown parameter type"));
+        throw std::logic_error(_("Unknown parameter type"));
       }
     } catch(std::exception& e) {
       // Just ignore this entry and continue with the rest
@@ -638,7 +639,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
     
     const char* configDir = os::getvncconfigdir();
     if (configDir == nullptr)
-      throw Exception(_("Could not determine VNC config directory path"));
+      throw std::runtime_error(_("Could not determine VNC config directory path"));
 
     snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
   } else {
@@ -657,9 +658,9 @@ void saveViewerParameters(const char *filename, const char *servername) {
 
   if (!encodeValue(servername, encodingBuffer, buffersize)) {
     fclose(f);
-    throw Exception(format(_("Failed to save \"%s\": %s"),
-                           "ServerName",
-                           _("Could not encode parameter")));
+    throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+                                    "ServerName",
+                                    _("Could not encode parameter")));
   }
   fprintf(f, "ServerName=%s\n", encodingBuffer);
 
@@ -668,9 +669,9 @@ void saveViewerParameters(const char *filename, const char *servername) {
       if (!encodeValue(*(StringParameter*)param,
           encodingBuffer, buffersize)) {
         fclose(f);
-        throw Exception(format(_("Failed to save \"%s\": %s"),
-                               param->getName(),
-                               _("Could not encode parameter")));
+        throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+                                        param->getName(),
+                                        _("Could not encode parameter")));
       }
       fprintf(f, "%s=%s\n", ((StringParameter*)param)->getName(), encodingBuffer);
     } else if (dynamic_cast<IntParameter*>(param) != nullptr) {
@@ -679,9 +680,9 @@ void saveViewerParameters(const char *filename, const char *servername) {
       fprintf(f, "%s=%d\n", ((BoolParameter*)param)->getName(), (int)*(BoolParameter*)param);
     } else {      
       fclose(f);
-      throw Exception(format(_("Failed to save \"%s\": %s"),
-                             param->getName(),
-                             _("Unknown parameter type")));
+      throw std::logic_error(format(_("Failed to save \"%s\": %s"),
+                                    param->getName(),
+                                    _("Unknown parameter type")));
     }
   }
   fclose(f);
@@ -700,7 +701,7 @@ static bool findAndSetViewerParameterFromValue(
     if (dynamic_cast<StringParameter*>(parameters[i]) != nullptr) {
       if (strcasecmp(line, ((StringParameter*)parameters[i])->getName()) == 0) {
         if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer)))
-          throw Exception(_("Invalid format or too large value"));
+          throw std::runtime_error(_("Invalid format or too large value"));
         ((StringParameter*)parameters[i])->setParam(decodingBuffer);
         return false;
       }
@@ -718,7 +719,7 @@ static bool findAndSetViewerParameterFromValue(
       }
 
     } else {
-      throw Exception(_("Unknown parameter type"));
+      throw std::logic_error(_("Unknown parameter type"));
     }
   }
 
@@ -744,7 +745,7 @@ char* loadViewerParameters(const char *filename) {
 
     const char* configDir = os::getvncconfigdir();
     if (configDir == nullptr)
-      throw Exception(_("Could not determine VNC config directory path"));
+      throw std::runtime_error(_("Could not determine VNC config directory path"));
 
     snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
   } else {
@@ -777,8 +778,11 @@ char* loadViewerParameters(const char *filename) {
 
     if (strlen(line) == (sizeof(line) - 1)) {
       fclose(f);
-      throw Exception(format(_("Failed to read line %d in file %s: %s"),
-                             lineNr, filepath, _("Line too long")));
+      throw std::runtime_error(format("%s: %s",
+                                      format(_("Failed to read line %d "
+                                               "in file \"%s\""),
+                                             lineNr, filepath).c_str(),
+                                      _("Line too long")));
     }
 
     // Make sure that the first line of the file has the file identifier string
@@ -787,8 +791,9 @@ char* loadViewerParameters(const char *filename) {
         continue;
 
       fclose(f);
-      throw Exception(format(_("Configuration file %s is in an invalid "
-                               "format"), filepath));
+      throw std::runtime_error(format(_("Configuration file %s is in "
+                                        "an invalid format"),
+                                      filepath));
     }
     
     // Skip empty lines and comments
@@ -822,7 +827,7 @@ char* loadViewerParameters(const char *filename) {
       if (strcasecmp(line, "ServerName") == 0) {
 
         if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer)))
-          throw Exception(_("Invalid format or too large value"));
+          throw std::runtime_error(_("Invalid format or too large value"));
         snprintf(servername, sizeof(decodingBuffer), "%s", decodingBuffer);
         invalidParameterName = false;
 
index 78a44f120c76eaa8fa92c2cbec58370c1e8fb06b..df3b8964cbc61325aec085b4b5d3f95435c5f940 100644 (file)
@@ -55,7 +55,6 @@
 #include <rfb/Hostname.h>
 #include <rfb/LogWriter.h>
 #include <rfb/Timer.h>
-#include <rfb/Exception.h>
 #include <rdr/Exception.h>
 #include <network/TcpSocket.h>
 #include <os/os.h>
@@ -757,7 +756,7 @@ int main(int argc, char** argv)
 
       createTcpListeners(&listeners, nullptr, port);
       if (listeners.empty())
-        throw Exception(_("Unable to listen for incoming connections"));
+        throw std::runtime_error(_("Unable to listen for incoming connections"));
 
       vlog.info(_("Listening on port %d"), port);
 
index fc0f689e628276d4691026e1e75a61fca838301b..2ca48dd6d8de635aaa3f0f9f9a7c448715cac9a2 100644 (file)
@@ -92,7 +92,7 @@ ImpersonateCurrentUser::ImpersonateCurrentUser() {
   if (!isServiceProcess())
     return;
   if (!token.canImpersonate())
-    throw rdr::Exception("Cannot impersonate unsafe or null token");
+    throw std::runtime_error("Cannot impersonate unsafe or null token");
   if (!ImpersonateLoggedOnUser(token)) {
     DWORD err = GetLastError();
     if (err != ERROR_CALL_NOT_IMPLEMENTED)
index ca6f3c9a4134aeef98a28d8e1fa2caddae828a57..62b917c0436654d3972b492820e393eda77a11a2 100644 (file)
@@ -56,7 +56,7 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
   uint8_t* new_data = nullptr;
 
   if (!pf.trueColour)
-    throw rfb::Exception("palette format not supported");
+    throw std::invalid_argument("palette format not supported");
 
   format = pf;
 
@@ -158,7 +158,7 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
       bits = bits >> 1;
     }
     if (depth > bpp)
-      throw Exception("Bad DIBSection format (depth exceeds bpp)");
+      throw std::runtime_error("Bad DIBSection format (depth exceeds bpp)");
 
     format = PixelFormat(bpp, depth, false, true,
                          redMax, greenMax, blueMax,
index fa0beaf96c75d5cc9940ee0163a964c295e1b65a..210bbf8025ce06ff2c33052c0893ff3f543ca307 100644 (file)
@@ -87,7 +87,7 @@ PixelFormat DeviceContext::getPF(HDC dc) {
         break;
       default:
         vlog.error("bits per pixel %u not supported", bi.bmiHeader.biBitCount);
-        throw rdr::Exception("unknown bits per pixel specified");
+        throw std::invalid_argument("unknown bits per pixel specified");
       };
       break;
     case BI_BITFIELDS:
index 752aeb4c7e078862461993a106493575a409559c..4da4d814a3939f3b3c415a63f6ad951e1cfd426d 100644 (file)
@@ -54,14 +54,14 @@ DeviceFrameBuffer::DeviceFrameBuffer(HDC deviceContext, const Rect& wRect)
 
   int capabilities = GetDeviceCaps(device, RASTERCAPS);
   if (!(capabilities & RC_BITBLT)) {
-    throw Exception("device does not support BitBlt");
+    throw std::invalid_argument("device does not support BitBlt");
   }
   if (!(capabilities & RC_DI_BITMAP)) {
-    throw Exception("device does not support GetDIBits");
+    throw std::invalid_argument("device does not support GetDIBits");
   }
   /*
   if (GetDeviceCaps(device, PLANES) != 1) {
-    throw Exception("device does not support planar displays");
+    throw std::invalid_argument("device does not support planar displays");
   }
   */
 
@@ -140,9 +140,9 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
     if (!GetObject(iconInfo.hbmMask, sizeof(BITMAP), &maskInfo))
       throw rdr::Win32Exception("GetObject() failed", GetLastError());
     if (maskInfo.bmPlanes != 1)
-      throw rdr::Exception("unsupported multi-plane cursor");
+      throw std::invalid_argument("unsupported multi-plane cursor");
     if (maskInfo.bmBitsPixel != 1)
-      throw rdr::Exception("unsupported cursor mask format");
+      throw std::invalid_argument("unsupported cursor mask format");
 
     width = maskInfo.bmWidth;
     height = maskInfo.bmHeight;
@@ -188,7 +188,7 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
       if ((bi.bV5RedMask != ((unsigned)0xff << ridx*8)) ||
           (bi.bV5GreenMask != ((unsigned)0xff << gidx*8)) ||
           (bi.bV5BlueMask != ((unsigned)0xff << bidx*8)))
-        throw rdr::Exception("unsupported cursor colour format");
+        throw std::invalid_argument("unsupported cursor colour format");
 
       uint8_t* rwbuffer = buffer.data();
       for (int y = 0; y < height; y++) {
index 3fcb96f700ca3349a09e59ef1fd0283ebfc37653..d5938e8d52f02036f69f20f961cb1d0161a1c7d4 100644 (file)
@@ -78,7 +78,7 @@ int Dialog::getItemInt(int id) {
   BOOL trans;
   int result = GetDlgItemInt(handle, id, &trans, TRUE);
   if (!trans)
-    throw rdr::Exception("unable to read dialog Int");
+    throw std::runtime_error("unable to read dialog Int");
   return result;
 }
 const char* Dialog::getItemString(int id) {
index f034d36d49d6fcdf2e495d2eac34f2a6f326ee9b..995c4fe209d6c2453d0c6d13af1277ea84b75a12 100644 (file)
@@ -22,8 +22,9 @@
 
 #include <windows.h>
 
+#include <stdexcept>
+
 #include <rfb_win32/EventManager.h>
-#include <rdr/Exception.h>
 #include <rfb/LogWriter.h>
 
 using namespace rfb;
@@ -59,7 +60,7 @@ void EventManager::removeEvent(HANDLE event) {
       return;
     }
   }
-  throw rdr::Exception("Event not registered");
+  throw std::runtime_error("Event not registered");
 }
 
 
index 15b2577627a8c112c45ccfca4c7160b37190c1aa..54de8928bff49b0ddf27161facc3d6d61624a10d 100644 (file)
@@ -247,14 +247,14 @@ std::string RegKey::getRepresentation(const char* valname) const {
       std::vector<char> expanded(required);
       length = ExpandEnvironmentStrings(str.c_str(), expanded.data(), required);
       if (required<length)
-        throw rdr::Exception("unable to expand environment strings");
+        throw std::runtime_error("unable to expand environment strings");
       return expanded.data();
     } else {
       return "";
     }
     }
   default:
-    throw rdr::Exception("unsupported registry type");
+    throw std::logic_error("unsupported registry type");
   }
 }
 
index 703334f3723a5ad686f252e9e03fc09b90d7391d..94b02a6df5486e9a03b81d9abefac76aa70b014d 100644 (file)
@@ -35,7 +35,6 @@
 #include <rfb_win32/MonitorInfo.h>
 #include <rfb_win32/SDisplayCorePolling.h>
 #include <rfb_win32/SDisplayCoreWMHooks.h>
-#include <rfb/Exception.h>
 #include <rfb/LogWriter.h>
 #include <rfb/ledStates.h>
 
@@ -172,12 +171,12 @@ void SDisplay::startCore() {
   // Currently, we just check whether we're in the console session, and
   //   fail if not
   if (!inConsoleSession())
-    throw rdr::Exception("Console is not session zero - oreconnect to restore Console sessin");
+    throw std::runtime_error("Console is not session zero - oreconnect to restore Console sessin");
   
   // Switch to the current input desktop
   if (rfb::win32::desktopChangeRequired()) {
     if (!rfb::win32::changeDesktop())
-      throw rdr::Exception("unable to switch into input desktop");
+      throw std::runtime_error("unable to switch into input desktop");
   }
 
   // Initialise the change tracker and clipper
@@ -200,7 +199,7 @@ void SDisplay::startCore() {
     } catch (std::exception& e) {
       delete core; core = nullptr;
       if (tryMethod == 0)
-        throw rdr::Exception("unable to access desktop");
+        throw std::runtime_error("unable to access desktop");
       tryMethod--;
       vlog.error("%s", e.what());
     }
@@ -435,7 +434,7 @@ SDisplay::processEvent(HANDLE event) {
     }
     return;
   }
-  throw rdr::Exception("No such event");
+  throw std::runtime_error("No such event");
 }
 
 
index 8165be3d622510bcfecc15f8d32e32ce450cfc7b..4c307600e5d99727b79666335905c6f55b840094 100644 (file)
@@ -40,7 +40,7 @@ SDisplayCoreWMHooks::SDisplayCoreWMHooks(SDisplay* d, UpdateTracker* ut)
   consolePollTimer(getHandle(), consolePollTimerId),
   pollConsoles(false) {
   if (!hooks.setEvent(display->getUpdateEvent()))
-    throw rdr::Exception("hook subsystem failed to initialise");
+    throw std::runtime_error("hook subsystem failed to initialise");
   poller.setUpdateTracker(updateTracker);
   cursorTimer.start(20);
   consolePollTimer.start(200);
index 04f9240213667449fa87ad79b2a46a5fe4b8c568..651537327d2925374ee629714c3327d99eba5b9a 100644 (file)
@@ -96,7 +96,7 @@ void AccessEntries::addEntry(const PSID sid,
 
 PSID Sid::copySID(const PSID sid) {
   if (!IsValidSid(sid))
-    throw rdr::Exception("invalid SID in copyPSID");
+    throw std::invalid_argument("invalid SID in copyPSID");
   PSID buf = (PSID)new uint8_t[GetLengthSid(sid)];
   if (!CopySid(GetLengthSid(sid), buf, sid))
     throw rdr::Win32Exception("CopySid failed", GetLastError());
@@ -105,7 +105,7 @@ PSID Sid::copySID(const PSID sid) {
 
 void Sid::setSID(const PSID sid) {
   if (!IsValidSid(sid))
-    throw rdr::Exception("invalid SID in copyPSID");
+    throw std::invalid_argument("invalid SID in copyPSID");
   resize(GetLengthSid(sid));
   if (!CopySid(GetLengthSid(sid), data(), sid))
     throw rdr::Win32Exception("CopySid failed", GetLastError());
index 6226e0332d3b6b4f59b09e1c0d9c2745f777fdb5..3d8c101e131bf7513d565d06947656321176c47f 100644 (file)
@@ -25,6 +25,8 @@
 #include <winsock2.h>
 #include <list>
 
+#include <rdr/Exception.h>
+
 #include <network/Socket.h>
 
 #include <rfb/LogWriter.h>
@@ -75,7 +77,7 @@ void SocketManager::addListener(network::SocketListener* sock_,
 
     // addEvent is the last thing we do, so that the event is NOT registered if previous steps fail
     if (!event || !addEvent(event, this))
-      throw rdr::Exception("Unable to add listener");
+      throw std::runtime_error("Unable to add listener");
   } catch (std::exception& e) {
     if (event)
       WSACloseEvent(event);
@@ -103,7 +105,7 @@ void SocketManager::remListener(network::SocketListener* sock) {
       return;
     }
   }
-  throw rdr::Exception("Listener not registered");
+  throw std::runtime_error("Listener not registered");
 }
 
 
@@ -136,7 +138,7 @@ void SocketManager::remSocket(network::Socket* sock_) {
       return;
     }
   }
-  throw rdr::Exception("Socket not registered");
+  throw std::runtime_error("Socket not registered");
 }
 
 bool SocketManager::getDisable(VNCServer* srvr)
@@ -147,7 +149,7 @@ bool SocketManager::getDisable(VNCServer* srvr)
       return i->second.disable;
     }
   }
-  throw rdr::Exception("Listener not registered");
+  throw std::runtime_error("Listener not registered");
 }
 
 void SocketManager::setDisable(VNCServer* srvr, bool disable)
@@ -163,7 +165,7 @@ void SocketManager::setDisable(VNCServer* srvr, bool disable)
     }
   }
   if (!found)
-    throw rdr::Exception("Listener not registered");
+    throw std::runtime_error("Listener not registered");
 }
 
 int SocketManager::checkTimeouts() {
index f7b5b6c731cbe44b7cc7268e62bb4af148213e9b..b22311af37af0af0a27432106e8b67cb0b485b6d 100644 (file)
@@ -81,7 +81,7 @@ const char* FileVersionInfo::getVerString(const char* name, DWORD langId) {
   UINT length = 0;
   if (!VerQueryValue(buf, infoName.c_str(), (void**)&buffer, &length)) {
     printf("unable to find %s version string", infoName.c_str());
-    throw rdr::Exception("VerQueryValue failed");
+    throw std::runtime_error("VerQueryValue failed");
   }
   return buffer;
 }
index 855d7363c369239b102d6e50fc0e3a5ce8bc3536..1edc2bfa69188136b08e217aab458b2e00d353b3 100644 (file)
@@ -85,7 +85,7 @@ void LegacyPage::LoadPrefs()
                     if (bits)
                       strcat(pattern, ".");
                     if (parts[j].size() > 3)
-                      throw rdr::Exception("Invalid IP address part");
+                      throw std::invalid_argument("Invalid IP address part");
                     if (!parts[j].empty()) {
                       strcat(pattern, parts[j].c_str());
                       bits += 8;
index 24918b2a1c113dae3bcb721d58b40c869ce8a61e..6ec62bbd56f7aa17cfbca72df60f6ea1af124e0f 100644 (file)
@@ -60,7 +60,7 @@ void QueryConnectDialog::worker() {
   countdown = timeout;
   try {
     if (desktopChangeRequired() && !changeDesktop())
-      throw rdr::Exception("changeDesktop failed");
+      throw std::runtime_error("changeDesktop failed");
     approve = Dialog::showDialog(MAKEINTRESOURCE(IDD_QUERY_CONNECT));
     server->queryConnectionComplete();
   } catch (...) {
index 25e6875fee4194ed0e033137a5a0c70277631835..4feff6b23ba91a5e8e9255804a0637872bbd39cb 100644 (file)
@@ -119,7 +119,7 @@ static void processParams(int argc, char** argv) {
         if (host != nullptr) {
           HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
           if (!hwnd)
-            throw rdr::Exception("Unable to locate existing VNC Server.");
+            throw std::runtime_error("Unable to locate existing VNC Server.");
           COPYDATASTRUCT copyData;
           copyData.dwData = 1; // *** AddNewClient
           copyData.cbData = strlen(host);
@@ -132,7 +132,7 @@ static void processParams(int argc, char** argv) {
         runServer = false;
         HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
         if (!hwnd)
-          throw rdr::Exception("Unable to locate existing VNC Server.");
+          throw std::runtime_error("Unable to locate existing VNC Server.");
         COPYDATASTRUCT copyData;
         copyData.dwData = 2; // *** DisconnectClients
         copyData.lpData = nullptr;