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", ""),
40 INVALID_OBSERVE_PARAM("INVALID_OBSERVE_PARAM", ""),
41 NO_MEMORY("NO_MEMORY", ""),
42 COMM_ERROR("COMM_ERROR", ""),
43 NOT_IMPL("NOTIMPL", ""),
44 NO_RESOURCE("NO_RESOURCE", "Resource not found"),
45 RESOURCE_ERROR("RESOURCE_ERROR", "Not supported method or interface"),
46 SLOW_RESOURCE("SLOW_RESOURCE", ""),
47 NO_OBSERVERS("NO_OBSERVERS", "Resource has no registered observers"),
48 OBSERVER_NOT_FOUND("OBSERVER_NOT_FOUND", ""),
49 PRESENCE_STOPPED("PRESENCE_STOPPED", ""),
50 PRESENCE_TIMEOUT("PRESENCE_TIMEOUT", ""),
51 PRESENCE_DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE", ""),
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_PLATFORM_INFO_PLATFORMID("INVALID_PLATFORM_INFO_PLATFORMID",
59 "PlatformID cannot be null or empty"),
60 INVALID_PLATFORM_INFO_MANUFACTURER_NAME("INVALID_PLATFORM_INFO_MANUFACTURER_NAME",
61 "ManufacturerName cannot be null, empty or greater than " +
62 OcStackConfig.MAX_MANUFACTURER_NAME_LENGTH + " characters long"),
63 INVALID_PLATFORM_INFO_PLATFORMID_MANUFACTURER_URL("INVALID_PLATFORM_INFO_MANUFACTURER_URL",
64 "MANUFACTURER_URL cannot be null, empty or greater than " +
65 OcStackConfig.MAX_MANUFACTURER_URL_LENGTH + " characters long"),
66 ERROR("ERROR", "Generic error"),
68 JNI_EXCEPTION("JNI_EXCEPTION", "Generic Java binder error"),
69 JNI_NO_NATIVE_OBJECT("JNI_NO_NATIVE_OBJECT", ""),
70 JNI_INVALID_VALUE("JNI_INVALID_VALUE", ""),
72 INVALID_CLASS_CAST("INVALID_CLASS_CAST", ""),;
75 private String description;
77 private ErrorCode(String error, String description) {
79 this.description = description;
82 public String getError() {
86 public String getDescription() {
90 public static ErrorCode get(String errorCode) {
91 for (ErrorCode eCode : ErrorCode.values()) {
92 if (eCode.getError().equals(errorCode)) {
96 throw new IllegalArgumentException("Unexpected ErrorCode value");
100 public String toString() {
101 return error + (description.isEmpty() ? "" : " : " + description);