aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr/InStream.h
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-09-02 22:58:35 +0200
committerPierre Ossman <ossman@cendio.se>2024-11-06 21:06:27 +0100
commit1d9b2f9984fefbc050c8e3295397ffd280e41788 (patch)
treec6fa8a4f5e0e6fbc0e165c2bd80b2c81a48bf6bc /common/rdr/InStream.h
parent5c3588c464520a4757bfc20974090e21af220cdc (diff)
downloadtigervnc-1d9b2f9984fefbc050c8e3295397ffd280e41788.tar.gz
tigervnc-1d9b2f9984fefbc050c8e3295397ffd280e41788.zip
Use standard exception classes
Use the more specific already included exception classes for common errors to keep things more understandable.
Diffstat (limited to 'common/rdr/InStream.h')
-rw-r--r--common/rdr/InStream.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/common/rdr/InStream.h b/common/rdr/InStream.h
index 939439e1..5623142c 100644
--- a/common/rdr/InStream.h
+++ b/common/rdr/InStream.h
@@ -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.