comparison dep/toml11/toml/exception.hpp @ 318:3b355fa948c7

config: use TOML instead of INI unfortunately, INI is not enough, and causes some paths including semicolons to break with our current storage of the library folders. so, I decided to switch to TOML which does support real arrays...
author Paper <paper@paper.us.eu.org>
date Wed, 12 Jun 2024 05:25:41 -0400
parents
children
comparison
equal deleted inserted replaced
317:b1f4d1867ab1 318:3b355fa948c7
1 // Copyright Toru Niina 2017.
2 // Distributed under the MIT License.
3 #ifndef TOML11_EXCEPTION_HPP
4 #define TOML11_EXCEPTION_HPP
5
6 #include <array>
7 #include <string>
8 #include <stdexcept>
9
10 #include <cstring>
11
12 #include "source_location.hpp"
13
14 namespace toml
15 {
16
17 struct file_io_error : public std::runtime_error
18 {
19 public:
20 file_io_error(int errnum, const std::string& msg, const std::string& fname)
21 : std::runtime_error(msg + " \"" + fname + "\": errno = " + std::to_string(errnum)),
22 errno_(errnum)
23 {}
24
25 int get_errno() const noexcept {return errno_;}
26
27 private:
28 int errno_;
29 };
30
31 struct exception : public std::exception
32 {
33 public:
34 explicit exception(const source_location& loc): loc_(loc) {}
35 virtual ~exception() noexcept override = default;
36 virtual const char* what() const noexcept override {return "";}
37 virtual source_location const& location() const noexcept {return loc_;}
38
39 protected:
40 source_location loc_;
41 };
42
43 struct syntax_error : public toml::exception
44 {
45 public:
46 explicit syntax_error(const std::string& what_arg, const source_location& loc)
47 : exception(loc), what_(what_arg)
48 {}
49 virtual ~syntax_error() noexcept override = default;
50 virtual const char* what() const noexcept override {return what_.c_str();}
51
52 protected:
53 std::string what_;
54 };
55
56 struct type_error : public toml::exception
57 {
58 public:
59 explicit type_error(const std::string& what_arg, const source_location& loc)
60 : exception(loc), what_(what_arg)
61 {}
62 virtual ~type_error() noexcept override = default;
63 virtual const char* what() const noexcept override {return what_.c_str();}
64
65 protected:
66 std::string what_;
67 };
68
69 struct internal_error : public toml::exception
70 {
71 public:
72 explicit internal_error(const std::string& what_arg, const source_location& loc)
73 : exception(loc), what_(what_arg)
74 {}
75 virtual ~internal_error() noexcept override = default;
76 virtual const char* what() const noexcept override {return what_.c_str();}
77
78 protected:
79 std::string what_;
80 };
81
82 } // toml
83 #endif // TOML_EXCEPTION