summaryrefslogtreecommitdiff
path: root/oss-fuzz/fuzzing/exception.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'oss-fuzz/fuzzing/exception.hpp')
-rw-r--r--oss-fuzz/fuzzing/exception.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/oss-fuzz/fuzzing/exception.hpp b/oss-fuzz/fuzzing/exception.hpp
new file mode 100644
index 00000000..55c360de
--- /dev/null
+++ b/oss-fuzz/fuzzing/exception.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <exception>
+#include <string>
+
+namespace fuzzing {
+namespace exception {
+
+class ExceptionBase : public std::exception {
+ public:
+ ExceptionBase(void) = default;
+ /* typeid(T).name */
+};
+
+/* Recoverable exception */
+class FlowException : public ExceptionBase {
+ public:
+ FlowException(void) : ExceptionBase() { }
+};
+
+/* Error in this library, should never happen */
+class LogicException : public ExceptionBase {
+ private:
+ std::string reason;
+ public:
+ LogicException(const std::string r) : ExceptionBase(), reason(r) { }
+ virtual const char* what(void) const throw() {
+ return reason.c_str();
+ }
+};
+
+/* Error in target application */
+class TargetException : public ExceptionBase {
+ private:
+ std::string reason;
+ public:
+ TargetException(const std::string r) : ExceptionBase(), reason(r) { }
+ virtual const char* what(void) const throw() {
+ return reason.c_str();
+ }
+};
+
+} /* namespace exception */
+} /* namespace fuzzing */