aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-04-11 22:23:57 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-04-11 22:23:57 +0100
commitf404efd0c7e58d2e68081bda38b27ae3b718842a (patch)
tree6128633e127cb9d412ddb4539b0af6432d704829
parent70cda1c1449fa0db8b891d7536a9e409cf44ce11 (diff)
downloadYAGE-f404efd0c7e58d2e68081bda38b27ae3b718842a.tar.gz
YAGE-f404efd0c7e58d2e68081bda38b27ae3b718842a.zip
Adding exceptions
-rw-r--r--yage/core/exception.cpp20
-rw-r--r--yage/core/exception.h23
2 files changed, 43 insertions, 0 deletions
diff --git a/yage/core/exception.cpp b/yage/core/exception.cpp
new file mode 100644
index 00000000..5cf525cc
--- /dev/null
+++ b/yage/core/exception.cpp
@@ -0,0 +1,20 @@
+#include "exception.h"
+
+namespace yage
+{
+
+FileLoadException::FileLoadException(std::string err) : std::runtime_error("File Load Exception")
+{
+ std::ostringstream msg("");
+
+ msg << runtime_error::what() << ": " << err;
+
+ err_msg = msg.str();
+}
+
+const char *FileLoadException::what() const throw()
+{
+ return err_msg.c_str();
+}
+
+} // namespace yage
diff --git a/yage/core/exception.h b/yage/core/exception.h
new file mode 100644
index 00000000..05733b39
--- /dev/null
+++ b/yage/core/exception.h
@@ -0,0 +1,23 @@
+#ifndef YAGE_CORE_EXCEPTION_H
+#define YAGE_CORE_EXCEPTION_H
+
+#include <stdexcept>
+#include <sstream>
+
+namespace yage
+{
+
+class FileLoadException : public std::runtime_error
+{
+public:
+ FileLoadException(std::string err);
+
+ virtual const char *what() const throw();
+
+private:
+ std::string err_msg;
+};
+
+} // namespace yage
+
+#endif