]> git.tdb.fi Git - libs/datafile.git/blob - source/except.h
Cosmetic changes
[libs/datafile.git] / source / except.h
1 #ifndef MSP_DATAFILE_EXCEPT_H_
2 #define MSP_DATAFILE_EXCEPT_H_
3
4 #include <stdexcept>
5 #include <string>
6 #include <typeinfo>
7
8 namespace Msp {
9 namespace DataFile {
10
11 class data_error: public std::runtime_error
12 {
13 private:
14         std::string source;
15         unsigned line = 0;
16
17 public:
18         data_error(const std::string &, unsigned, const std::string &);
19         data_error(const std::string &, unsigned, const std::exception &);
20         data_error(const std::string &, unsigned, const data_error &);
21         ~data_error() throw() override = default;
22
23         const std::string &get_source() const { return source; }
24         unsigned get_line() const { return line; }
25
26 private:
27         std::string make_what(const std::string &, unsigned, const std::string &);
28 };
29
30
31 class parse_error: public std::runtime_error
32 {
33 public:
34         parse_error(const std::string &);
35         ~parse_error() throw() override = default;
36 };
37
38
39 class syntax_error: public std::runtime_error
40 {
41 public:
42         syntax_error(const std::string &t);
43         ~syntax_error() throw() override = default;
44 };
45
46
47 class bad_definition: public std::runtime_error
48 {
49 public:
50         bad_definition(const std::string &w);
51         ~bad_definition() throw() override = default;
52 };
53
54
55 class nesting_error: public std::logic_error
56 {
57 public:
58         nesting_error(const std::string &);
59         ~nesting_error() throw() override = default;
60 };
61
62
63 class unknown_keyword: public std::runtime_error
64 {
65 public:
66         unknown_keyword(const std::string &);
67         ~unknown_keyword() throw() override = default;
68 };
69
70
71 class invalid_signature: public std::runtime_error
72 {
73 public:
74         invalid_signature(const std::string &, const std::string &);
75         ~invalid_signature() throw() override = default;
76 };
77
78
79 class no_collection: public std::runtime_error
80 {
81 public:
82         no_collection(const std::type_info &);
83 };
84
85 } // namespace DataFile
86 } // namespace Msp
87
88 #endif