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 resource-encapsulation
26 #ifndef RES_ENCAPSULATION_RCSEXCEPTION_H
27 #define RES_ENCAPSULATION_RCSEXCEPTION_H
33 #include "boost/config.hpp"
41 * The base exception class for resource encapsulation.
44 class RCSException: public std::exception
49 * Constructs an exception with an empty description.
51 * @see RCSException(const std::string &)
52 * @see RCSException(std::string &&)
57 * Constructs an exception with a description.
59 * @param what The description for the error.
61 * @see RCSException(std::string &&)
63 explicit RCSException(const std::string &what);
68 * @param what The description for the error.
70 * @see RCSException(const std::string &)
72 explicit RCSException(std::string &&what);
74 virtual ~RCSException() BOOST_NOEXCEPT;
77 * Returns the exception description.
80 virtual const char *what() const BOOST_NOEXCEPT;
84 * Exception description
86 const std::string m_what;
90 * Thrown when OC layer returns an error.
93 class RCSPlatformException: public RCSException
96 explicit RCSPlatformException(OCStackResult reason);
102 OCStackResult getReasonCode() const;
105 * Returns the reason description.
108 std::string getReason() const;
111 OCStackResult m_reason;
115 * Thrown when a request is not acceptable.
118 class RCSBadRequestException: public RCSException
121 explicit RCSBadRequestException(const std::string& what);
122 explicit RCSBadRequestException(std::string&& what);
126 * Thrown when a parameter is not valid.
129 class RCSInvalidParameterException: public RCSException
132 explicit RCSInvalidParameterException(const std::string& what);
133 explicit RCSInvalidParameterException(std::string&& what);
137 * Thrown when getting value with wrong template parameter.
139 class RCSBadGetException: public RCSException
142 explicit RCSBadGetException(const std::string& what);
143 explicit RCSBadGetException(std::string&& what);
147 * Thrown when a key is invalid.
150 class RCSInvalidKeyException: public RCSException
153 explicit RCSInvalidKeyException(const std::string& what);
154 explicit RCSInvalidKeyException(std::string&& what);
160 #endif // RES_ENCAPSULATION_RCSEXCEPTION_H