1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 #ifndef EASY_SETUP_EXCEPTION_H
23 #define EASY_SETUP_EXCEPTION_H
30 * This file contains the declaration of exception classes for easy setup
38 * The base exception class for resource encapsulation.
41 class ESException: public std::exception
46 * Constructs an exception with an empty description.
51 * Constructs an exception with a description.
53 * @param what The description for the error.
55 explicit ESException(const std::string &what);
60 explicit ESException(std::string &&what);
62 virtual ~ESException() noexcept;
65 * Returns the exception description.
68 virtual const char *what() const noexcept;
72 * Exception description
74 const std::string m_what;
78 * Thrown when OC layer returns an error.
81 class ESPlatformException: public ESException
86 * Constructs an exception with a description.
88 * @param OCStackResult The description for the error.
90 explicit ESPlatformException(OCStackResult reason);
96 OCStackResult getReasonCode() const;
99 * This function returns description of the exception.
102 std::string getReason() const;
105 OCStackResult m_reason;
109 * Thrown when a request is not acceptable.
112 class ESBadRequestException: public ESException
116 * Constructs an exception with a description.
118 * @param OCStackResult The description for the error.
120 explicit ESBadRequestException(const std::string& what);
124 explicit ESBadRequestException(std::string&& what);
128 * Thrown when a parameter is not valid.
131 class ESInvalidParameterException: public ESException
135 * Constructs an exception with a description.
137 * @param OCStackResult The description for the error.
139 explicit ESInvalidParameterException(const std::string& what);
143 explicit ESInvalidParameterException(std::string&& what);
147 * Thrown when getting value with wrong template parameter.
149 class ESBadGetException: public ESException
153 * Constructs an exception with a description.
155 * @param OCStackResult The description for the error.
157 explicit ESBadGetException(const std::string& what);
161 explicit ESBadGetException(std::string&& what);
165 * Thrown when a key is invalid.
168 class ESInvalidKeyException: public ESException
172 * Constructs an exception with a description.
174 * @param OCStackResult The description for the error.
176 explicit ESInvalidKeyException(const std::string& what);
180 explicit ESInvalidKeyException(std::string&& what);
185 #endif // EASY_SETUP_EXCEPTION_H