Add missing enum value of OCStackResult to switch in reason() function of OCException...
[platform/upstream/iotivity.git] / resource / 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 #include "StringConstants.h"
23
24 std::string OC::OCException::reason(const OCStackResult sr)
25 {
26     switch(sr)
27     {
28         case OC_STACK_OK:
29              return OC::Exception::NO_ERROR;
30         case OC_STACK_RESOURCE_CREATED:
31              return OC::Exception::RESOURCE_CREATED;
32         case OC_STACK_RESOURCE_DELETED:
33              return OC::Exception::RESOURCE_DELETED;
34         case OC_STACK_CONTINUE:
35              return OC::Exception::STACK_CONTINUE;
36         case OC_STACK_INVALID_URI:
37             return OC::Exception::INVALID_URI;
38         case OC_STACK_INVALID_QUERY:
39             return OC::Exception::INVALID_QUERY;
40         case OC_STACK_INVALID_IP:
41             return OC::Exception::INVALID_IP;
42         case OC_STACK_INVALID_PORT:
43             return OC::Exception::INVALID_PORT;
44         case OC_STACK_INVALID_CALLBACK:
45             return OC::Exception::INVALID_CB;
46         case OC_STACK_INVALID_METHOD:
47             return OC::Exception::INVALID_METHOD;
48         case OC_STACK_INVALID_PARAM:
49             return OC::Exception::INVALID_PARAM;
50         case OC_STACK_INVALID_OBSERVE_PARAM:
51             return OC::Exception::INVALID_OBESERVE;
52         case OC_STACK_NO_MEMORY:
53             return OC::Exception::NO_MEMORY;
54         case OC_STACK_COMM_ERROR:
55             return OC::Exception::COMM_ERROR;
56         case OC_STACK_NOTIMPL:
57             return OC::Exception::NOT_IMPL;
58         case OC_STACK_NO_RESOURCE:
59             return OC::Exception::NOT_FOUND;
60         case OC_STACK_RESOURCE_ERROR:
61             return OC::Exception::RESOURCE_ERROR;
62         case OC_STACK_SLOW_RESOURCE:
63             return OC::Exception::SLOW_RESOURCE;
64         case OC_STACK_REPEATED_REQUEST:
65             return OC::Exception::REPEATED_REQUEST;
66         case OC_STACK_NO_OBSERVERS:
67             return OC::Exception::NO_OBSERVERS;
68         case OC_STACK_OBSERVER_NOT_FOUND:
69             return OC::Exception::OBSV_NO_FOUND;
70         case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
71             return OC::Exception::VIRTUAL_DO_NOT_HANDLE;
72         case OC_STACK_INVALID_OPTION:
73             return OC::Exception::INVALID_OPTION;
74         case OC_STACK_MALFORMED_RESPONSE:
75             return OC::Exception::MALFORMED_STACK_RESPONSE;
76         case OC_STACK_PERSISTENT_BUFFER_REQUIRED:
77             return OC::Exception::PERSISTENT_BUFFER_REQUIRED;
78         case OC_STACK_INVALID_REQUEST_HANDLE:
79             return OC::Exception::INVALID_REQUEST_HANDLE;
80         case OC_STACK_INVALID_DEVICE_INFO:
81             return OC::Exception::INVALID_DEVICE_INFO;
82 #ifdef WITH_PRESENCE
83         case OC_STACK_PRESENCE_STOPPED:
84             return OC::Exception::PRESENCE_STOPPED;
85         case OC_STACK_PRESENCE_TIMEOUT:
86             return OC::Exception::PRESENCE_TIMEOUT;
87         case OC_STACK_PRESENCE_DO_NOT_HANDLE:
88             return OC::Exception::PRESENCE_NOT_HANDLED;
89 #endif
90         case OC_STACK_ERROR:
91             return OC::Exception::GENERAL_FAULT;
92     }
93
94     return OC::Exception::UNKNOWN_ERROR;
95 }
96