OpenZWave Library
1.6.1914
Toggle main menu visibility
Loading...
Searching...
No Matches
cpp
src
OZWException.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
//
3
// FatalErrorException.h
4
//
5
// Exception Handling Code
6
//
7
// Copyright (c) 2014 Justin Hammond <justin@dynam.ac>
8
//
9
// SOFTWARE NOTICE AND LICENSE
10
//
11
// This file is part of OpenZWave.
12
//
13
// OpenZWave is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU Lesser General Public License as published
15
// by the Free Software Foundation, either version 3 of the License,
16
// or (at your option) any later version.
17
//
18
// OpenZWave is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
// GNU Lesser General Public License for more details.
22
//
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25
//
26
//-----------------------------------------------------------------------------
27
28
#ifndef _FatalErrorException_H
29
#define _FatalErrorException_H
30
31
#include <stdexcept>
32
#include <iostream>
33
#include <string>
34
#include <sstream>
35
36
namespace
OpenZWave
37
{
43
44
class
OPENZWAVE_EXPORT
OZWException
:
public
std::runtime_error
45
{
46
public
:
47
enum
ExceptionType
48
{
49
OZWEXCEPTION_OPTIONS
,
50
OZWEXCEPTION_CONFIG
,
51
OZWEXCEPTION_INVALID_HOMEID
= 100,
52
OZWEXCEPTION_INVALID_VALUEID
,
53
OZWEXCEPTION_CANNOT_CONVERT_VALUEID
,
54
OZWEXCEPTION_SECURITY_FAILED
,
55
OZWEXCEPTION_INVALID_NODEID
56
};
57
58
//-----------------------------------------------------------------------------
59
// Construction
60
//-----------------------------------------------------------------------------
61
OZWException
(std::string file,
int
line,
ExceptionType
exitCode, std::string msg) :
62
std
::runtime_error(
OZWException
::GetExceptionText(file, line, exitCode, msg)),
63
m_exitCode(exitCode),
64
m_file(file),
65
m_line(line),
66
m_msg(msg)
67
{
68
}
69
70
~OZWException
() throw()
71
{
72
}
73
74
//-----------------------------------------------------------------------------
75
// Accessor methods
76
//-----------------------------------------------------------------------------
77
ExceptionType
GetType
()
78
{
return
m_exitCode;}
79
std::string
GetFile
()
80
{
return
m_file;}
81
uint32
GetLine
()
82
{
return
m_line;}
83
std::string
GetMsg
()
84
{
return
m_msg;}
85
86
private
:
87
static
std::string GetExceptionText(std::string file,
int
line, ExceptionType exitCode, std::string msg)
88
{
89
std::stringstream ss;
90
ss << file.substr(file.find_last_of(
"/\\"
) + 1) <<
":"
<< line;
91
switch
(exitCode)
92
{
93
case
OZWEXCEPTION_OPTIONS:
94
ss <<
" - OptionsError ("
<< exitCode <<
") Msg: "
<< msg;
95
break
;
96
case
OZWEXCEPTION_CONFIG:
97
ss <<
" - ConfigError ("
<< exitCode <<
") Msg: "
<< msg;
98
break
;
99
case
OZWEXCEPTION_INVALID_HOMEID:
100
ss <<
" - InvalidHomeIDError ("
<< exitCode <<
") Msg: "
<< msg;
101
break
;
102
case
OZWEXCEPTION_INVALID_VALUEID:
103
ss <<
" - InvalidValueIDError ("
<< exitCode <<
") Msg: "
<< msg;
104
break
;
105
case
OZWEXCEPTION_CANNOT_CONVERT_VALUEID:
106
ss <<
" - CannotConvertValueIDError ("
<< exitCode <<
") Msg: "
<< msg;
107
break
;
108
case
OZWEXCEPTION_SECURITY_FAILED:
109
ss <<
" - Security Initialization Failed ("
<< exitCode <<
") Msg: "
<< msg;
110
break
;
111
case
OZWEXCEPTION_INVALID_NODEID:
112
ss <<
" - InvalidNodeIDError ("
<< exitCode <<
") Msg: "
<< msg;
113
break
;
114
}
115
return
ss.str();
116
}
117
118
//-----------------------------------------------------------------------------
119
// Member variables
120
//-----------------------------------------------------------------------------
121
ExceptionType m_exitCode;
122
std::string m_file;
123
uint32
m_line;
124
std::string m_msg;
125
};
126
}
127
128
#endif
// _FatalErrorException_H
uint32
unsigned int uint32
Definition
Defs.h:91
OPENZWAVE_EXPORT
#define OPENZWAVE_EXPORT
Definition
Defs.h:52
OpenZWave::OZWException::GetFile
std::string GetFile()
Definition
OZWException.h:79
OpenZWave::OZWException::GetLine
uint32 GetLine()
Definition
OZWException.h:81
OpenZWave::OZWException::OZWException
OZWException(std::string file, int line, ExceptionType exitCode, std::string msg)
Definition
OZWException.h:61
OpenZWave::OZWException::ExceptionType
ExceptionType
Definition
OZWException.h:48
OpenZWave::OZWException::OZWEXCEPTION_OPTIONS
@ OZWEXCEPTION_OPTIONS
Definition
OZWException.h:49
OpenZWave::OZWException::OZWEXCEPTION_INVALID_NODEID
@ OZWEXCEPTION_INVALID_NODEID
Definition
OZWException.h:55
OpenZWave::OZWException::OZWEXCEPTION_INVALID_VALUEID
@ OZWEXCEPTION_INVALID_VALUEID
Definition
OZWException.h:52
OpenZWave::OZWException::OZWEXCEPTION_CANNOT_CONVERT_VALUEID
@ OZWEXCEPTION_CANNOT_CONVERT_VALUEID
Definition
OZWException.h:53
OpenZWave::OZWException::OZWEXCEPTION_SECURITY_FAILED
@ OZWEXCEPTION_SECURITY_FAILED
Definition
OZWException.h:54
OpenZWave::OZWException::OZWEXCEPTION_CONFIG
@ OZWEXCEPTION_CONFIG
Definition
OZWException.h:50
OpenZWave::OZWException::OZWEXCEPTION_INVALID_HOMEID
@ OZWEXCEPTION_INVALID_HOMEID
Definition
OZWException.h:51
OpenZWave::OZWException::~OZWException
~OZWException()
Definition
OZWException.h:70
OpenZWave::OZWException::GetType
ExceptionType GetType()
Definition
OZWException.h:77
OpenZWave::OZWException::GetMsg
std::string GetMsg()
Definition
OZWException.h:83
OpenZWave
Definition
Bitfield.cpp:31
std
STL namespace.
Generated on
for OpenZWave Library by
1.17.0