aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mglpp/mglpp.hpp10
-rw-r--r--src/mglpp.cpp3
2 files changed, 12 insertions, 1 deletions
diff --git a/include/mglpp/mglpp.hpp b/include/mglpp/mglpp.hpp
index 6e790af..dacd134 100644
--- a/include/mglpp/mglpp.hpp
+++ b/include/mglpp/mglpp.hpp
@@ -1,9 +1,19 @@
#ifndef MGLPP_MGLPP_HPP
#define MGLPP_MGLPP_HPP
+#include <stdexcept>
+
namespace mgl {
+ class InitException : public std::exception {
+ public:
+ const char* what() const noexcept override {
+ return "Failed to initialize mgl";
+ }
+ };
+
class Init {
public:
+ // Throws InitException on failure
Init();
~Init();
};
diff --git a/src/mglpp.cpp b/src/mglpp.cpp
index 6bf6307..1719d85 100644
--- a/src/mglpp.cpp
+++ b/src/mglpp.cpp
@@ -5,7 +5,8 @@ extern "C" {
namespace mgl {
Init::Init() {
- mgl_init();
+ if(mgl_init() != 0)
+ throw InitException();
}
Init::~Init() {