]> git.tdb.fi Git - libs/datafile.git/blob - source/except.cpp
Cosmetic changes
[libs/datafile.git] / source / except.cpp
1 #include <msp/debug/demangle.h>
2 #include <msp/strings/format.h>
3 #include "except.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace DataFile {
9
10 data_error::data_error(const string &s, unsigned l, const string &w):
11         runtime_error(make_what(s, l, w)),
12         source(s),
13         line(l)
14 { }
15
16 data_error::data_error(const string &s, unsigned l, const exception &e):
17         runtime_error(make_what(s, l, format("%s (%s)", Debug::demangle(typeid(e).name()), e.what()))),
18         source(s),
19         line(l)
20 { }
21
22 data_error::data_error(const string &s, unsigned l, const data_error &e):
23         runtime_error(format("%s\n%s", e.what(), make_what(s, l, "Referenced here"))),
24         source(s),
25         line(l)
26 { }
27
28 string data_error::make_what(const string &s, unsigned l, const string &w)
29 {
30         if(l)
31                 return format("%s:%d: %s", s, l, w);
32         else
33                 return format("%s: %s", s, w);
34 }
35
36
37 parse_error::parse_error(const string &t):
38         runtime_error(t.empty() ? "at end of input" : format("after '%s'", t))
39 { }
40
41
42 syntax_error::syntax_error(const string &t):
43         runtime_error(t.empty() ? "at end of input" : format("at '%s'", t))
44 { }
45
46
47 bad_definition::bad_definition(const string &w):
48         runtime_error(w)
49 { }
50
51
52 nesting_error::nesting_error(const string &w):
53         logic_error(w)
54 { }
55
56
57 unknown_keyword::unknown_keyword(const string &k):
58         runtime_error(k)
59 { }
60
61
62 invalid_signature::invalid_signature(const string &k, const string &s):
63         runtime_error(format("%s %s", k, s))
64 { }
65
66
67 no_collection::no_collection(const type_info &t):
68         runtime_error(Debug::demangle(t.name()))
69 { }
70
71 } // namespace DataFile
72 } // namespace Msp