Arduino KVComm
master
Key-Value pair communication library for Arduino
src
KVComm
include
KVComm
KV_Error.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#if !defined(ARDUINO) || defined(DOXYGEN)
4
5
#include <sstream>
6
#include <stdexcept>
7
#include <string>
8
11
13
class
KV_Exception
:
public
std::exception {
14
public
:
15
KV_Exception
(
const
std::string
message
,
int
errorCode
)
16
:
message
(
std
::move(
message
)),
errorCode
(
errorCode
) {}
17
const
char
*
what
()
const
throw()
override
{
return
message
.c_str(); }
18
int
getErrorCode
()
const
{
return
errorCode
; }
19
20
private
:
21
const
std::string
message
;
22
const
int
errorCode
;
23
};
24
26
#define KV_ERROR(msg, errc) \
27
do { \
28
std::ostringstream s; \
29
s << __PRETTY_FUNCTION__ << ":" << __LINE__ << msg; \
30
throw KV_Exception(s.str(), errc); \
31
} while (0)
32
34
35
#ifdef ARDUINO_TEST
36
#include <
AH/PrintStream/PrintStream.hpp
>
37
#else
38
#define F(x) (x)
39
#endif
40
41
#else
42
43
#include <
AH/Error/Error.hpp
>
44
45
#define KV_ERROR(msg, errc) ERROR(msg, errc)
46
47
#endif
KV_Exception::errorCode
const int errorCode
Definition:
KV_Error.hpp:22
Error.hpp
KV_Exception::getErrorCode
int getErrorCode() const
Definition:
KV_Error.hpp:18
KV_Exception::KV_Exception
KV_Exception(const std::string message, int errorCode)
Definition:
KV_Error.hpp:15
KV_Exception::what
const char * what() const override
Definition:
KV_Error.hpp:17
std
Definition:
vector.cpp:5
PrintStream.hpp
KV_Exception::message
const std::string message
Definition:
KV_Error.hpp:21
KV_Exception
Custom exception for KVComm. Not used on Arduino.
Definition:
KV_Error.hpp:13
Generated by
1.8.16