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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file contains the declaration of exception classes for easy setup
26 #ifndef EASY_SETUP_EXCEPTION_H
27 #define EASY_SETUP_EXCEPTION_H
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
84 explicit ESPlatformException(OCStackResult reason);
90 OCStackResult getReasonCode() const;
93 * Returns the reason description.
96 std::string getReason() const;
99 OCStackResult m_reason;
103 * Thrown when a request is not acceptable.
106 class ESBadRequestException: public ESException
109 explicit ESBadRequestException(const std::string& what);
110 explicit ESBadRequestException(std::string&& what);
114 * Thrown when a parameter is not valid.
117 class ESInvalidParameterException: public ESException
120 explicit ESInvalidParameterException(const std::string& what);
121 explicit ESInvalidParameterException(std::string&& what);
125 * Thrown when getting value with wrong template parameter.
127 class ESBadGetException: public ESException
130 explicit ESBadGetException(const std::string& what);
131 explicit ESBadGetException(std::string&& what);
135 * Thrown when a key is invalid.
138 class ESInvalidKeyException: public ESException
141 explicit ESInvalidKeyException(const std::string& what);
142 explicit ESInvalidKeyException(std::string&& what);
147 #endif // EASY_SETUP_EXCEPTION_H