toml11/toml/exception.hpp

55 lines
1.5 KiB
C++
Raw Normal View History

2018-12-13 11:44:10 +00:00
// Copyright Toru Niina 2017.
// Distributed under the MIT License.
2017-04-21 04:14:53 +00:00
#ifndef TOML11_EXCEPTION
#define TOML11_EXCEPTION
#include <stdexcept>
#include <string>
namespace toml
{
struct exception : public std::exception
{
public:
2017-06-12 13:04:59 +00:00
virtual ~exception() noexcept override = default;
2017-04-21 04:14:53 +00:00
virtual const char* what() const noexcept override {return "";}
};
struct syntax_error : public toml::exception
{
public:
explicit syntax_error(const std::string& what_arg) : what_(what_arg){}
explicit syntax_error(const char* what_arg) : what_(what_arg){}
2017-06-12 13:04:59 +00:00
virtual ~syntax_error() noexcept override = default;
2017-04-21 04:14:53 +00:00
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) : what_(what_arg){}
explicit type_error(const char* what_arg) : what_(what_arg){}
2017-06-12 13:04:59 +00:00
virtual ~type_error() noexcept override = default;
2017-04-21 04:14:53 +00:00
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) : what_(what_arg){}
explicit internal_error(const char* what_arg) : what_(what_arg){}
2017-06-12 13:04:59 +00:00
virtual ~internal_error() noexcept override = default;
2017-04-21 04:14:53 +00:00
virtual const char* what() const noexcept override {return what_.c_str();}
protected:
std::string what_;
};
} // toml
#endif // TOML_EXCEPTION