RDK Documentation (Open Sourced RDK Components)
exception.hpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 
23 /**
24 * @defgroup devicesettings
25 * @{
26 * @defgroup rpc
27 * @{
28 **/
29 
30 
31 #ifndef _DS_MGR_EXCEPTION_H_
32 #define _DS_MGR_EXCEPTION_H_
33 #ifndef _DS_EXCEPTION_H_
34 #define _DS_EXCEPTION_H_
35 
36 #include <string>
37 #include <iostream>
38 #include <exception>
39 
40 namespace device {
41 
42 class Exception : public std::exception {
43  int _err;
44  std::string _msg;
45 
46 public:
47  Exception(const char *msg = "No Message for this exception") throw() : _msg(msg) {
48  }
49 
50  Exception(int err, const char *msg = "No Message for this Exception") throw()
51  : _err(err), _msg(msg){
52  };
53  virtual const std::string & getMessage() const {
54  return _msg;
55  }
56  virtual int getCode() const {
57  return _err;
58  }
59  virtual const char * what() const throw() {
60  return _msg.c_str();
61  }
62 
63  virtual ~Exception() throw() {};
64 };
65 
66 }
67 #endif /* EXCEPTION_H_ */
68 #endif
69 
70 
71 /** @} */
72 /** @} */
device::Exception::what
virtual const char * what() const
This function is overwritten to get the null terminated character sequence of the exception message.
Definition: exception.hpp:116
device::Exception::~Exception
virtual ~Exception()
This function is the default destructor of Exception class.
Definition: exception.hpp:127
device::Exception::Exception
Exception(const char *msg="No Message for this exception")
This function is a parameterised constructor of the class Exception. It initializes the instance with...
Definition: exception.hpp:67
device::Exception::getCode
virtual int getCode() const
This function is used to get the error code of the exception.
Definition: exception.hpp:104
device::Exception::_err
int _err
Indicates error code for the exception.
Definition: exception.hpp:53
device::Exception::getMessage
virtual const std::string & getMessage() const
This function is used to get the message string of the exception.
Definition: exception.hpp:93
device::Exception::_msg
std::string _msg
Indicates the error message.
Definition: exception.hpp:54
Exception
Definition: Exception.hpp:42