Newer
Older
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
#include "http_err.hpp"
HttpException::HttpException(const HttpException::Type &type, const std::string &message)
{
this->error_type = type;
this->message = std::string(HttpException::typeToString(type)) + ": " + message;
}
HttpException::HttpException(const HttpException::Type &type)
: HttpException(type, "?")
{ }
const char * HttpException::what()
const noexcept
{
return message.c_str();
}
const HttpException::Type & HttpException::getType()
const noexcept
{
return error_type;
}
const char * HttpException::typeToString(const HttpException::Type & type)
{
switch (type)
{
case Generic:
return "HttpException::Generic";
case SocketOpen:
return "HttpException::SocketOpen";
case InvalidIP:
return "HttpException::InvalidIP";
case SocketBind:
return "HttpException::SocketBind";
case TcpAccept:
return "HttpException::TcpAccept";
case TcpSend:
return "HttpException::TcpSend";
}
return "HttpException::NoType";
}