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 defines a class to handle exception thrown for resource encapsulation.
27 #ifndef RES_ENCAPSULATION_RCSEXCEPTION_H
28 #define RES_ENCAPSULATION_RCSEXCEPTION_H
40 * The base exception class for resource encapsulation.
43 class RCSException: public std::exception
48 * Constructs an exception with an empty description.
53 * Constructs an exception with a description.
55 * @param what The description for the error.
57 explicit RCSException(const std::string &what);
62 explicit RCSException(std::string &&what);
64 virtual ~RCSException() noexcept;
67 * Returns the exception description.
70 virtual const char *what() const noexcept;
74 * Exception description
76 const std::string m_what;
80 * Thrown when OC layer returns an error.
83 class PlatformException: public RCSException
86 explicit PlatformException(OCStackResult reason);
92 OCStackResult getReasonCode() const;
95 * Returns the reason description.
98 std::string getReason() const;
101 OCStackResult m_reason;
105 * Thrown when a request is not acceptable.
108 class BadRequestException: public RCSException
111 explicit BadRequestException(const std::string& what);
112 explicit BadRequestException(std::string&& what);
116 * Thrown when a parameter is not valid.
119 class InvalidParameterException: public RCSException
122 explicit InvalidParameterException(const std::string& what);
123 explicit InvalidParameterException(std::string&& what);
127 * Thrown when getting value with wrong template parameter.
129 class BadGetException: public RCSException
132 explicit BadGetException(const std::string& what);
133 explicit BadGetException(std::string&& what);
137 * Thrown when a key is invalid.
140 class InvalidKeyException: public RCSException
143 explicit InvalidKeyException(const std::string& what);
144 explicit InvalidKeyException(std::string&& what);
150 #endif // RES_ENCAPSULATION_RCSEXCEPTION_H