Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / common / primitiveResource / src / RCSException.cpp
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #include <RCSException.h>
22
23 #include <OCException.h>
24
25 namespace OIC
26 {
27     namespace Service
28     {
29
30         RCSException::RCSException()
31         {
32         }
33
34         RCSException::RCSException(const std::string& what) :
35                 m_what{ what }
36         {
37         }
38
39         RCSException::RCSException(std::string&& what) :
40                 m_what{ std::move(what) }
41         {
42         }
43
44         RCSException::~RCSException() noexcept
45         {
46         }
47
48         const char* RCSException::what() const noexcept
49         {
50             return m_what.c_str();
51         }
52
53
54         PlatformException::PlatformException(OCStackResult reason) :
55                 RCSException{ "Failed : " + OC::OCException::reason(reason) },
56                 m_reason { reason }
57         {
58         }
59
60         OCStackResult PlatformException::getReasonCode() const
61         {
62             return m_reason;
63         }
64
65         std::string PlatformException::getReason() const
66         {
67             return  OC::OCException::reason(m_reason);
68         }
69
70
71         BadRequestException::BadRequestException(const std::string& what) :
72                 RCSException{ what }
73         {
74         }
75
76         BadRequestException::BadRequestException(std::string&& what) :
77                 RCSException{ std::move(what) }
78         {
79         }
80
81
82         InvalidParameterException::InvalidParameterException(const std::string& what) :
83                 RCSException{ what }
84         {
85         }
86
87         InvalidParameterException::InvalidParameterException(std::string&& what) :
88                 RCSException{ std::move(what) }
89         {
90         }
91
92
93         BadGetException::BadGetException(const std::string& what) :
94                 RCSException{ what }
95         {
96         }
97
98         BadGetException::BadGetException(std::string&& what) :
99                 RCSException{ std::move(what) }
100         {
101         }
102
103
104         InvalidKeyException::InvalidKeyException(const std::string& what) :
105                 RCSException{ what }
106         {
107         }
108
109         InvalidKeyException::InvalidKeyException(std::string&& what) :
110                 RCSException{ std::move(what) }
111         {
112         }
113     }
114 }