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