-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptions.cpp
More file actions
99 lines (79 loc) · 1.5 KB
/
Exceptions.cpp
File metadata and controls
99 lines (79 loc) · 1.5 KB
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
#include "Exceptions.hpp"
// virtual destructor of base class
ExceptionBase::~ExceptionBase()
{}
// output
std::ostream &
operator<< (std::ostream &out, const ExceptionBase &exc)
{
exc.print(out);
return out;
}
/*
---------------------------
TypeError functions
---------------------------
*/
TypeError::TypeError(const std::string &msg_src) : msg(msg_src)
{}
void
TypeError::print(std::ostream &out) const
{
out << TYPE_ERR_MSG << msg;
}
std::string
TypeError::get_msg() const
{
return TYPE_ERR_MSG + msg;
}
/*
---------------------------
SockError functions
---------------------------
*/
SockError::SockError(const std::string &msg_src) : msg(msg_src)
{}
void
SockError::print(std::ostream &out) const
{
out << SOCK_ERR_MSG << msg;
}
std::string
SockError::get_msg() const
{
return SOCK_ERR_MSG + msg;
}
/*
---------------------------
FileError functions
---------------------------
*/
FileError::FileError(const std::string &msg_src) : msg(msg_src)
{}
void
FileError::print(std::ostream &out) const
{
out << FILE_ERR_MSG << msg;
}
std::string
FileError::get_msg() const
{
return FILE_ERR_MSG + msg;
}
/*
---------------------------
SizeError functions
---------------------------
*/
SizeError::SizeError(size_t num_src) : num(num_src)
{}
void
SizeError::print(std::ostream &out) const
{
out << SIZE_ERR_MSG << num;
}
std::string
SizeError::get_msg() const
{
return SIZE_ERR_MSG + std::to_string(num);
}