aboutsummaryrefslogtreecommitdiff
path: root/src/toml11/toml/exception.hpp
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2022-03-01 13:58:17 +0100
committerGitHub <noreply@github.com>2022-03-01 13:58:17 +0100
commit47dec825c5daeeb9d615eb4d1eead3dbaa06c7c9 (patch)
tree9d4426dfe847570906487649c32c5b320697705c /src/toml11/toml/exception.hpp
parent79152e307e7eef667c3de9c21571d017654a7c32 (diff)
parentdc92b01885c0c49d094148b1c4dc871ccdd265ad (diff)
Merge pull request #6181 from obsidiansystems/auto-uid-allocation
Auto uid allocation -- update with latest master
Diffstat (limited to 'src/toml11/toml/exception.hpp')
-rw-r--r--src/toml11/toml/exception.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/toml11/toml/exception.hpp b/src/toml11/toml/exception.hpp
new file mode 100644
index 000000000..c64651d0a
--- /dev/null
+++ b/src/toml11/toml/exception.hpp
@@ -0,0 +1,65 @@
+// Copyright Toru Niina 2017.
+// Distributed under the MIT License.
+#ifndef TOML11_EXCEPTION_HPP
+#define TOML11_EXCEPTION_HPP
+#include <stdexcept>
+#include <string>
+
+#include "source_location.hpp"
+
+namespace toml
+{
+
+struct exception : public std::exception
+{
+ public:
+ explicit exception(const source_location& loc): loc_(loc) {}
+ virtual ~exception() noexcept override = default;
+ virtual const char* what() const noexcept override {return "";}
+ virtual source_location const& location() const noexcept {return loc_;}
+
+ protected:
+ source_location loc_;
+};
+
+struct syntax_error : public toml::exception
+{
+ public:
+ explicit syntax_error(const std::string& what_arg, const source_location& loc)
+ : exception(loc), what_(what_arg)
+ {}
+ virtual ~syntax_error() noexcept override = default;
+ virtual const char* what() const noexcept override {return what_.c_str();}
+
+ protected:
+ std::string what_;
+};
+
+struct type_error : public toml::exception
+{
+ public:
+ explicit type_error(const std::string& what_arg, const source_location& loc)
+ : exception(loc), what_(what_arg)
+ {}
+ virtual ~type_error() noexcept override = default;
+ virtual const char* what() const noexcept override {return what_.c_str();}
+
+ protected:
+ std::string what_;
+};
+
+struct internal_error : public toml::exception
+{
+ public:
+ explicit internal_error(const std::string& what_arg, const source_location& loc)
+ : exception(loc), what_(what_arg)
+ {}
+ virtual ~internal_error() noexcept override = default;
+ virtual const char* what() const noexcept override {return what_.c_str();}
+
+ protected:
+ std::string what_;
+};
+
+} // toml
+#endif // TOML_EXCEPTION