1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH 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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "OCException.h"
22 #include "StringConstants.h"
24 std::string OC::OCException::reason(const OCStackResult sr)
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_INVALID_URI:
35 return OC::Exception::INVALID_URI;
36 case OC_STACK_INVALID_IP:
37 return OC::Exception::INVALID_IP;
38 case OC_STACK_INVALID_PORT:
39 return OC::Exception::INVALID_PORT;
40 case OC_STACK_INVALID_CALLBACK:
41 return OC::Exception::INVALID_CB;
42 case OC_STACK_INVALID_METHOD:
43 return OC::Exception::INVALID_METHOD;
44 case OC_STACK_INVALID_QUERY:
45 return OC::Exception::INVALID_QUERY;
46 case OC_STACK_INVALID_PARAM:
47 return OC::Exception::INVALID_PARAM;
48 case OC_STACK_INVALID_OBSERVE_PARAM:
49 return OC::Exception::INVALID_OBESERVE;
50 case OC_STACK_NO_MEMORY:
51 return OC::Exception::NO_MEMORY;
52 case OC_STACK_COMM_ERROR:
53 return OC::Exception::COMM_ERROR;
54 case OC_STACK_TIMEOUT:
55 return OC::Exception::TIMEOUT;
56 case OC_STACK_ADAPTER_NOT_ENABLED:
57 return OC::Exception::ADAPTER_NOT_ENABLED;
58 case OC_STACK_NOTIMPL:
59 return OC::Exception::NOT_IMPL;
60 case OC_STACK_NO_RESOURCE:
61 return OC::Exception::NOT_FOUND;
62 case OC_STACK_RESOURCE_ERROR:
63 return OC::Exception::RESOURCE_ERROR;
64 case OC_STACK_SLOW_RESOURCE:
65 return OC::Exception::SLOW_RESOURCE;
66 case OC_STACK_DUPLICATE_REQUEST:
67 return OC::Exception::DUPLICATE_REQUEST;
68 case OC_STACK_NO_OBSERVERS:
69 return OC::Exception::NO_OBSERVERS;
70 case OC_STACK_OBSERVER_NOT_FOUND:
71 return OC::Exception::OBSV_NO_FOUND;
73 case OC_STACK_PRESENCE_STOPPED:
74 return OC::Exception::PRESENCE_STOPPED;
75 case OC_STACK_PRESENCE_TIMEOUT:
76 return OC::Exception::PRESENCE_TIMEOUT;
77 case OC_STACK_PRESENCE_DO_NOT_HANDLE:
78 return OC::Exception::PRESENCE_NOT_HANDLED;
80 case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
81 return OC::Exception::VIRTUAL_DO_NOT_HANDLE;
82 case OC_STACK_INVALID_OPTION:
83 return OC::Exception::INVALID_OPTION;
84 case OC_STACK_MALFORMED_RESPONSE:
85 return OC::Exception::MALFORMED_STACK_RESPONSE;
86 case OC_STACK_PERSISTENT_BUFFER_REQUIRED:
87 return OC::Exception::PERSISTENT_BUFFER_REQUIRED;
88 case OC_STACK_CONTINUE:
89 return OC::Exception::STACK_CONTINUE;
90 case OC_STACK_INVALID_REQUEST_HANDLE:
91 return OC::Exception::INVALID_REQUEST_HANDLE;
93 return OC::Exception::GENERAL_FAULT;
94 case OC_STACK_INVALID_DEVICE_INFO:
95 return OC::Exception::INVALID_DEVICE_INFO;
96 case OC_STACK_INVALID_JSON:
97 return OC::Exception::INVALID_REPRESENTATION;
98 case OC_STACK_UNAUTHORIZED_REQ:
99 return OC::Exception::UNAUTHORIZED_REQUEST;
100 case OC_STACK_PDM_IS_NOT_INITIALIZED:
101 return OC::Exception::PDM_DB_NOT_INITIALIZED;
102 case OC_STACK_DUPLICATE_UUID:
103 return OC::Exception::DUPLICATE_UUID;
104 case OC_STACK_INCONSISTENT_DB:
105 return OC::Exception::INCONSISTENT_DB;
106 case OC_STACK_AUTHENTICATION_FAILURE:
107 return OC::Exception::AUTHENTICATION_FAILURE;
110 return OC::Exception::UNKNOWN_ERROR;