]> git.tdb.fi Git - libs/datafile.git/blob - source/except.h
Move all exception classes to a common header
[libs/datafile.git] / source / except.h
1 #ifndef MSP_DATAFILE_EXCEPT_H_
2 #define MSP_DATAFILE_EXCEPT_H_
3
4 #include <stdexcept>
5
6 namespace Msp {
7 namespace DataFile {
8
9 class data_error: public std::runtime_error
10 {
11 private:
12         std::string source;
13         unsigned line;
14
15 public:
16         data_error(const std::string &, unsigned, const std::string &);
17         data_error(const std::string &, unsigned, const std::exception &);
18         virtual ~data_error() throw() { }
19
20         const std::string &get_source() const { return source; }
21         unsigned get_line() const { return line; }
22
23 private:
24         std::string make_what(const std::string &, unsigned, const std::string &);
25 };
26
27
28 class parse_error: public std::runtime_error
29 {
30 public:
31         parse_error(const std::string &);
32         virtual ~parse_error() throw() { }
33 };
34
35
36 class syntax_error: public std::runtime_error
37 {
38 public:
39         syntax_error(const std::string &t);
40         virtual ~syntax_error() throw() { }
41 };
42
43
44 class bad_definition: public std::runtime_error
45 {
46 public:
47         bad_definition(const std::string &w);
48         virtual ~bad_definition() throw() { }
49 };
50
51
52 class nesting_error: public std::logic_error
53 {
54 public:
55         nesting_error(const std::string &);
56         virtual ~nesting_error() throw() { }
57 };
58
59 } // namespace DataFile
60 } // namespace Msp
61
62 #endif