/
exceptions.h
106 lines (89 loc) · 1.83 KB
/
exceptions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef NEWSBOAT_EXCEPTIONS_H_
#define NEWSBOAT_EXCEPTIONS_H_
#include <sqlite3.h>
#include <stdexcept>
#include <string>
#include "configparser.h"
namespace newsboat {
class xmlexception : public std::exception {
public:
explicit xmlexception(const std::string& errmsg)
: msg(errmsg)
{
}
~xmlexception() throw() override {}
const char* what() const throw() override
{
return msg.c_str();
}
private:
std::string msg;
};
class configexception : public std::exception {
public:
explicit configexception(const std::string& errmsg)
: msg(errmsg)
{
}
~configexception() throw() override {}
const char* what() const throw() override
{
return msg.c_str();
}
private:
std::string msg;
};
class confighandlerexception : public std::exception {
public:
explicit confighandlerexception(const std::string& emsg)
: msg(emsg)
{
}
explicit confighandlerexception(action_handler_status e);
~confighandlerexception() throw() override {}
const char* what() const throw() override
{
return msg.c_str();
}
int status()
{
return 0;
}
private:
const char* get_errmsg(action_handler_status e);
std::string msg;
};
class dbexception : public std::exception {
public:
explicit dbexception(sqlite3* h)
: msg(sqlite3_errmsg(h))
{
}
~dbexception() throw() override {}
const char* what() const throw() override
{
return msg.c_str();
}
private:
std::string msg;
};
class matcherexception : public std::exception {
public:
enum class type { ATTRIB_UNAVAIL, INVALID_REGEX };
matcherexception(type et,
const std::string& info,
const std::string& info2 = "")
: type_(et)
, addinfo(info)
, addinfo2(info2)
{
}
~matcherexception() throw() override {}
const char* what() const throw() override;
private:
type type_;
std::string addinfo;
std::string addinfo2;
};
} // namespace newsboat
#endif /* NEWSBOAT_EXCEPTIONS_H_ */