Added commentary to the public API referring to new functionality of
[platform/upstream/iotivity.git] / src / OCException.cpp
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH 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 "OCException.h"
22
23 std::string OC::OCException::reason(const OCStackResult sr)
24 {
25     switch(sr)
26     {
27         case OC_STACK_OK:
28              return "No Error";
29         case OC_STACK_RESOURCE_CREATED:
30              return "Resource Created";
31         case OC_STACK_RESOURCE_DELETED:
32              return "Resource Deleted";
33         case OC_STACK_INVALID_URI:
34             return "Invalid URI";
35         case OC_STACK_INVALID_IP:
36             return "Invalid IP";
37         case OC_STACK_INVALID_PORT:
38             return "Invalid Port";
39         case OC_STACK_INVALID_CALLBACK:
40             return "Invalid Callback";
41         case OC_STACK_INVALID_METHOD:
42             return "Invalid Method";
43         case OC_STACK_INVALID_QUERY:
44             return "Invalid Query";
45         case OC_STACK_INVALID_PARAM:
46             return "Invalid Parameter";
47         case OC_STACK_INVALID_OBSERVE_PARAM:
48             return "Invalid Observe Parameter";
49         case OC_STACK_NO_MEMORY:
50             return "No Memory";
51         case OC_STACK_COMM_ERROR:
52             return "Communication Error";
53         case OC_STACK_NOTIMPL:
54             return "Not Implemented";
55         case OC_STACK_NO_RESOURCE:
56             return "Resource Not Found";
57         case OC_STACK_RESOURCE_ERROR:
58             return "Resource Error";
59         case OC_STACK_SLOW_RESOURCE:
60             return "Slow Resource";
61         case OC_STACK_NO_OBSERVERS:
62             return "No Observers";
63        case OC_STACK_OBSERVER_NOT_FOUND:
64             return "Stack observer not found";
65        case OC_STACK_OBSERVER_NOT_ADDED:
66             return "Stack observer not added";
67        case OC_STACK_OBSERVER_NOT_REMOVED:
68             return "Stack observer not removed";
69 #ifdef WITH_PRESENCE
70        case OC_STACK_PRESENCE_STOPPED:
71             return "Stack presence stopped";
72        case OC_STACK_PRESENCE_DO_NOT_HANDLE:
73             return "Stack presence should not be handled";
74 #endif
75        case OC_STACK_INVALID_OPTION:
76             return "Invalid option";
77        case OC_STACK_MALFORMED_RESPONSE:
78             return "Malformed response";
79        case OC_STACK_ERROR:
80             return "General Fault";
81     }
82
83     return "Unknown Error";
84 }
85