-
Notifications
You must be signed in to change notification settings - Fork 3
/
exception.hpp
57 lines (49 loc) · 1.3 KB
/
exception.hpp
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
#include <string>
#include <stdexcept>
class exception : public std::runtime_error
{
public:
exception(const std::string& msg) : std::runtime_error(msg)
{
}
exception(const std::string& msg1, const std::string& msg2)
: std::runtime_error(msg1 + " "+ msg2)
{}
exception(const std::string& msg1, const std::string& msg2, const std::string& msg3)
: std::runtime_error(msg1 + " "+ msg2 + " " + msg3)
{}
};
class connection_close : public exception
{
public:
connection_close(const std::string& msg) : exception(msg)
{
}
};
class transport_error : public exception
{
public:
transport_error(const std::string& msg)
: exception("Transport error: " + msg)
{}
};
class protocol_error : public exception
{
public:
protocol_error(const std::string& retmsg)
: exception("Protocol error [" + retmsg + "]")
{}
protocol_error(const std::string& cmd, const std::string& retmsg)
: exception("Protocol error [" + cmd + "] [" + retmsg + "]")
{}
protocol_error(const std::string& cmd, const std::string& arg, const std::string& retmsg)
: exception("Protocol error [" + cmd + " " + arg + "] [" + retmsg + "]")
{}
};
class not_found : public exception
{
public:
not_found(const std::string& msg)
: exception(msg)
{}
};