2 * //******************************************************************
4 * // Copyright 2015 Intel Corporation.
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * // Licensed under the Apache License, Version 2.0 (the "License");
9 * // you may not use this file except in compliance with the License.
10 * // You may obtain a copy of the License at
12 * // http://www.apache.org/licenses/LICENSE-2.0
14 * // Unless required by applicable law or agreed to in writing, software
15 * // distributed under the License is distributed on an "AS IS" BASIS,
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * // See the License for the specific language governing permissions and
18 * // limitations under the License.
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 package org.iotivity.base;
25 public enum ErrorCode {
26 /* Success status code - START HERE */
28 RESOURCE_CREATED("RESOURCE_CREATED", ""),
29 RESOURCE_DELETED("RESOURCE_DELETED", ""),
30 CONTINUE("CONTINUE", ""),
31 /** Success status code - END HERE.*/
32 /* Error status code - START HERE */
33 INVALID_URI("INVALID_URI", ""),
34 INVALID_QUERY("INVALID_QUERY", ""),
35 INVALID_IP("INVALID_IP", ""),
36 INVALID_PORT("INVALID_PORT", ""),
37 INVALID_CALLBACK("INVALID_CALLBACK", ""),
38 INVALID_METHOD("INVALID_METHOD", ""),
39 INVALID_PARAM("INVALID_PARAM", "Invalid parameter"),
40 INVALID_OBSERVE_PARAM("INVALID_OBSERVE_PARAM", ""),
41 NO_MEMORY("NO_MEMORY", ""),
42 COMM_ERROR("COMM_ERROR", ""),
43 TIMEOUT("TIMEOUT", ""),
44 ADAPTER_NOT_ENABLED("ADAPTER_NOT_ENABLED", ""),
45 NOT_IMPL("NOTIMPL", ""),
46 NO_RESOURCE("NO_RESOURCE", "Resource not found"),
47 RESOURCE_ERROR("RESOURCE_ERROR", "Not supported method or interface"),
48 SLOW_RESOURCE("SLOW_RESOURCE", ""),
49 DUPLICATE_REQUEST("DUPLICATE_REQUEST", ""),
50 NO_OBSERVERS("NO_OBSERVERS", "Resource has no registered observers"),
51 OBSERVER_NOT_FOUND("OBSERVER_NOT_FOUND", ""),
52 VIRTUAL_DO_NOT_HANDLE("VIRTUAL_DO_NOT_HANDLE", ""),
53 INVALID_OPTION("INVALID_OPTION", ""),
54 MALFORMED_RESPONSE("MALFORMED_RESPONSE", "Remote reply contained malformed data"),
55 PERSISTENT_BUFFER_REQUIRED("PERSISTENT_BUFFER_REQUIRED", ""),
56 INVALID_REQUEST_HANDLE("INVALID_REQUEST_HANDLE", ""),
57 INVALID_DEVICE_INFO("INVALID_DEVICE_INFO", ""),
58 INVALID_JSON("INVALID_JSON", ""),
59 UNAUTHORIZED_REQ("UNAUTHORIZED_REQ", "Request is not authorized by Resource Server"),
60 /** Error code from PDM */
61 PDM_IS_NOT_INITIALIZED("PDM_IS_NOT_INITIALIZED", ""),
62 DUPLICATE_UUID("DUPLICATE_UUID", ""),
63 INCONSISTENT_DB("INCONSISTENT_DB", ""),
64 /** Error code from OTM */
65 AUTHENTICATION_FAILURE("AUTHENTICATION_FAILURE",
66 "This error is pushed from DTLS interface when handshake failure happens"),
67 /** Insert all new error codes here!.*/
68 PRESENCE_STOPPED("PRESENCE_STOPPED", ""),
69 PRESENCE_TIMEOUT("PRESENCE_TIMEOUT", ""),
70 PRESENCE_DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE", ""),
72 ERROR("ERROR", "Generic error"),
74 JNI_EXCEPTION("JNI_EXCEPTION", "Generic Java binder error"),
75 JNI_NO_NATIVE_OBJECT("JNI_NO_NATIVE_OBJECT", ""),
76 JNI_INVALID_VALUE("JNI_INVALID_VALUE", ""),
77 INVALID_CLASS_CAST("INVALID_CLASS_CAST", ""),;
80 private String description;
82 private ErrorCode(String error, String description) {
84 this.description = description;
87 public String getError() {
91 public String getDescription() {
95 public static ErrorCode get(String errorCode) {
96 for (ErrorCode eCode : ErrorCode.values()) {
97 if (eCode.getError().equals(errorCode)) {
101 throw new IllegalArgumentException("Unexpected ErrorCode value");
105 public String toString() {
106 return error + (description.isEmpty() ? "" : " : " + description);