forked from halfgaar/FlashMQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.h
81 lines (65 loc) · 1.98 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
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#ifndef EXCEPTIONS_H
#define EXCEPTIONS_H
#include <exception>
#include <stdexcept>
#include <sstream>
#include "types.h"
/**
* @brief The ProtocolError class is handled by the error handler in the worker threads and is used to make decisions about if and how
* to inform a client and log the message.
*
* It's mainly meant for errors that can be communicated with MQTT packets.
*/
class ProtocolError : public std::runtime_error
{
public:
const ReasonCodes reasonCode;
ProtocolError(const std::string &msg, ReasonCodes reasonCode = ReasonCodes::UnspecifiedError) : std::runtime_error(msg),
reasonCode(reasonCode)
{
}
};
class BadClientException : public std::runtime_error
{
public:
BadClientException(const std::string &msg) : std::runtime_error(msg) {}
};
class NotImplementedException : public std::runtime_error
{
public:
NotImplementedException(const std::string &msg) : std::runtime_error(msg) {}
};
class FatalError : public std::runtime_error
{
public:
FatalError(const std::string &msg) : std::runtime_error(msg) {}
};
class ConfigFileException : public std::runtime_error
{
public:
ConfigFileException(const std::string &msg) : std::runtime_error(msg) {}
ConfigFileException(std::ostringstream oss) : std::runtime_error(oss.str()) {}
};
class pluginException : public std::runtime_error
{
public:
pluginException(const std::string &msg) : std::runtime_error(msg) {}
};
class BadWebsocketVersionException : public std::runtime_error
{
public:
BadWebsocketVersionException(const std::string &msg) : std::runtime_error(msg) {}
};
class BadHttpRequest : public std::runtime_error
{
public:
BadHttpRequest(const std::string &msg) : std::runtime_error(msg) {}
};
#endif // EXCEPTIONS_H