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
39 * The base exception class for resource encapsulation.
42 class RCSException: public std::exception
47 * Constructs an exception with an empty description.
52 * Constructs an exception with a description.
54 * @param what The description for the error.
56 explicit RCSException(const std::string &what);
61 explicit RCSException(std::string &&what);
63 virtual ~RCSException() noexcept;
66 * Returns the exception description.
69 virtual const char *what() const noexcept;
73 * Exception description
75 const std::string m_what;
79 * Thrown when OC layer returns an error.
82 class RCSPlatformException: public RCSException
85 explicit RCSPlatformException(OCStackResult reason);
91 OCStackResult getReasonCode() const;
94 * Returns the reason description.
97 std::string getReason() const;
100 OCStackResult m_reason;
104 * Thrown when a request is not acceptable.
107 class RCSBadRequestException: public RCSException
110 explicit RCSBadRequestException(const std::string& what);
111 explicit RCSBadRequestException(std::string&& what);
115 * Thrown when a parameter is not valid.
118 class RCSInvalidParameterException: public RCSException
121 explicit RCSInvalidParameterException(const std::string& what);
122 explicit RCSInvalidParameterException(std::string&& what);
126 * Thrown when getting value with wrong template parameter.
128 class RCSBadGetException: public RCSException
131 explicit RCSBadGetException(const std::string& what);
132 explicit RCSBadGetException(std::string&& what);
136 * Thrown when a key is invalid.
139 class RCSInvalidKeyException: public RCSException
142 explicit RCSInvalidKeyException(const std::string& what);
143 explicit RCSInvalidKeyException(std::string&& what);
149 #endif // RES_ENCAPSULATION_RCSEXCEPTION_H