summaryrefslogtreecommitdiff
path: root/project2/exceptions.h
diff options
context:
space:
mode:
Diffstat (limited to 'project2/exceptions.h')
-rw-r--r--project2/exceptions.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/project2/exceptions.h b/project2/exceptions.h
index d156636..b6c64ae 100644
--- a/project2/exceptions.h
+++ b/project2/exceptions.h
@@ -3,15 +3,32 @@
#include <stdexcept>
-class UriElementOutOfRange : public std::exception { };
-class ParamNotFound : public std::exception { };
-class NotSupported : public std::runtime_error {
+class numeric_error : public std::exception {
public:
- NotSupported(const std::string & what);
+ numeric_error(int);
+ ~numeric_error() throw();
+ const char * what() const throw();
+ private:
+ int err;
+ mutable char * buf;
};
-class FileNotReadable : public std::exception { };
-class FileNotWritable : public std::exception { };
-class FilterNotFound : public std::exception { };
+#define SimpleMessageException(Name) \
+class Name : public std::runtime_error { \
+ public: \
+ Name(const std::string & what) : std::runtime_error(what) { } \
+}
+#define SimpleNumericException(Name) \
+class Name : public numeric_error { \
+ public: \
+ Name(int e) : numeric_error(e) { } \
+}
+
+SimpleNumericException(UriElementOutOfRange);
+SimpleMessageException(ParamNotFound);
+SimpleMessageException(NotSupported);
+SimpleMessageException(FileNotReadable);
+SimpleMessageException(FileNotWritable);
+SimpleMessageException(FilterNotFound);
#endif