1 /* 2 * Copyright (c) 2020.Huawei Technologies Co., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ERROR_CODE_H 17 #define ERROR_CODE_H 18 #include <string> 19 20 using APP_ERROR = int; 21 // define the data tpye of error code 22 enum { 23 APP_ERR_OK = 0, 24 25 // define the error code of ACL model, this is same with the aclError which is 26 // error code of ACL API Error codes 1~999 are reserved for the ACL. Do not 27 // add other error codes. Add it after APP_ERR_COMMON_ERR_BASE. 28 APP_ERR_ACL_FAILURE = -1, // ACL: general error 29 APP_ERR_ACL_ERR_BASE = 0, 30 APP_ERR_ACL_INVALID_PARAM = 1, // ACL: invalid parameter 31 APP_ERR_ACL_BAD_ALLOC = 2, // ACL: memory allocation fail 32 APP_ERR_ACL_RT_FAILURE = 3, // ACL: runtime failure 33 APP_ERR_ACL_GE_FAILURE = 4, // ACL: Graph Engine failure 34 APP_ERR_ACL_OP_NOT_FOUND = 5, // ACL: operator not found 35 APP_ERR_ACL_OP_LOAD_FAILED = 6, // ACL: fail to load operator 36 APP_ERR_ACL_READ_MODEL_FAILURE = 7, // ACL: fail to read model 37 APP_ERR_ACL_PARSE_MODEL = 8, // ACL: parse model failure 38 APP_ERR_ACL_MODEL_MISSING_ATTR = 9, // ACL: model missing attribute 39 APP_ERR_ACL_DESERIALIZE_MODEL = 10, // ACL: deserialize model failure 40 APP_ERR_ACL_EVENT_NOT_READY = 12, // ACL: event not ready 41 APP_ERR_ACL_EVENT_COMPLETE = 13, // ACL: event complete 42 APP_ERR_ACL_UNSUPPORTED_DATA_TYPE = 14, // ACL: unsupported data type 43 APP_ERR_ACL_REPEAT_INITIALIZE = 15, // ACL: repeat initialize 44 APP_ERR_ACL_COMPILER_NOT_REGISTERED = 16, // ACL: compiler not registered 45 APP_ERR_ACL_IO = 17, // ACL: IO failed 46 APP_ERR_ACL_INVALID_FILE = 18, // ACL: invalid file 47 APP_ERR_ACL_INVALID_DUMP_CONFIG = 19, // ACL: invalid dump comfig 48 APP_ERR_ACL_INVALID_PROFILING_CONFIG = 20, // ACL: invalid profiling config 49 APP_ERR_ACL_OP_TYPE_NOT_MATCH = 21, // ACL: operator type not match 50 APP_ERR_ACL_OP_INPUT_NOT_MATCH = 22, // ACL: operator input not match 51 APP_ERR_ACL_OP_OUTPUT_NOT_MATCH = 23, // ACL: operator output not match 52 APP_ERR_ACL_OP_ATTR_NOT_MATCH = 24, // ACL: operator attribute not match 53 APP_ERR_ACL_API_NOT_SUPPORT = 25, // ACL: API not support 54 APP_ERR_ACL_CREATE_DATA_BUF_FAILED = 26, // ACL: create data buffer fail 55 APP_ERR_ACL_END, // Not an error code, define the range of ACL error code 56 57 // define the common error code, range: 1001~1999 58 APP_ERR_COMM_BASE = 1000, 59 APP_ERR_COMM_FAILURE = APP_ERR_COMM_BASE + 1, // General Failed 60 APP_ERR_COMM_INNER = APP_ERR_COMM_BASE + 2, // Internal error 61 APP_ERR_COMM_INVALID_POINTER = APP_ERR_COMM_BASE + 3, // Invalid Pointer 62 APP_ERR_COMM_INVALID_PARAM = APP_ERR_COMM_BASE + 4, // Invalid parameter 63 APP_ERR_COMM_UNREALIZED = APP_ERR_COMM_BASE + 5, // Not implemented 64 APP_ERR_COMM_OUT_OF_MEM = APP_ERR_COMM_BASE + 6, // Out of memory 65 APP_ERR_COMM_ALLOC_MEM = APP_ERR_COMM_BASE + 7, // memory allocation error 66 APP_ERR_COMM_FREE_MEM = APP_ERR_COMM_BASE + 8, // free memory error 67 APP_ERR_COMM_OUT_OF_RANGE = APP_ERR_COMM_BASE + 9, // out of range 68 APP_ERR_COMM_NO_PERMISSION = APP_ERR_COMM_BASE + 10, // NO Permission 69 APP_ERR_COMM_TIMEOUT = APP_ERR_COMM_BASE + 11, // Timed out 70 APP_ERR_COMM_NOT_INIT = APP_ERR_COMM_BASE + 12, // Not initialized 71 APP_ERR_COMM_INIT_FAIL = APP_ERR_COMM_BASE + 13, // initialize failed 72 APP_ERR_COMM_INPROGRESS = APP_ERR_COMM_BASE + 14, // Operation now in progress 73 APP_ERR_COMM_EXIST = APP_ERR_COMM_BASE + 15, // Object, file or other resource already exist 74 APP_ERR_COMM_NO_EXIST = APP_ERR_COMM_BASE + 16, // Object, file or other resource doesn't exist 75 APP_ERR_COMM_BUSY = APP_ERR_COMM_BASE + 17, // Object, file or other resource is in use 76 APP_ERR_COMM_FULL = APP_ERR_COMM_BASE + 18, // No available Device or resource 77 APP_ERR_COMM_OPEN_FAIL = APP_ERR_COMM_BASE + 19, // Device, file or resource open failed 78 APP_ERR_COMM_READ_FAIL = APP_ERR_COMM_BASE + 20, // Device, file or resource read failed 79 APP_ERR_COMM_WRITE_FAIL = APP_ERR_COMM_BASE + 21, // Device, file or resource write failed 80 APP_ERR_COMM_DESTORY_FAIL = APP_ERR_COMM_BASE + 22, // Device, file or resource destory failed 81 APP_ERR_COMM_EXIT = APP_ERR_COMM_BASE + 23, // End of data stream, stop the application 82 APP_ERR_COMM_CONNECTION_CLOSE = APP_ERR_COMM_BASE + 24, // Out of connection, Communication shutdown 83 APP_ERR_COMM_CONNECTION_FAILURE = APP_ERR_COMM_BASE + 25, // connection fail 84 APP_ERR_COMM_STREAM_INVALID = APP_ERR_COMM_BASE + 26, // ACL stream is null pointer 85 APP_ERR_COMM_END, // Not an error code, define the range of common error code 86 87 // define the error code of DVPP 88 APP_ERR_DVPP_BASE = 2000, 89 APP_ERR_DVPP_CROP_FAIL = APP_ERR_DVPP_BASE + 1, // DVPP: crop fail 90 APP_ERR_DVPP_RESIZE_FAIL = APP_ERR_DVPP_BASE + 2, // DVPP: resize fail 91 APP_ERR_DVPP_CROP_RESIZE_FAIL = APP_ERR_DVPP_BASE + 3, // DVPP: corp and resize fail 92 APP_ERR_DVPP_CONVERT_FROMAT_FAIL = APP_ERR_DVPP_BASE + 4, // DVPP: convert image fromat fail 93 APP_ERR_DVPP_VPC_FAIL = APP_ERR_DVPP_BASE + 5, // DVPP: VPC(crop, resize, convert fromat) fail 94 APP_ERR_DVPP_JPEG_DECODE_FAIL = APP_ERR_DVPP_BASE + 6, // DVPP: decode jpeg or jpg fail 95 APP_ERR_DVPP_JPEG_ENCODE_FAIL = APP_ERR_DVPP_BASE + 7, // DVPP: encode jpeg or jpg fail 96 APP_ERR_DVPP_PNG_DECODE_FAIL = APP_ERR_DVPP_BASE + 8, // DVPP: encode png fail 97 APP_ERR_DVPP_H26X_DECODE_FAIL = APP_ERR_DVPP_BASE + 9, // DVPP: decode H264 or H265 fail 98 APP_ERR_DVPP_H26X_ENCODE_FAIL = APP_ERR_DVPP_BASE + 10, // DVPP: encode H264 or H265 fail 99 APP_ERR_DVPP_HANDLE_NULL = APP_ERR_DVPP_BASE + 11, // DVPP: acldvppChannelDesc is nullptr 100 APP_ERR_DVPP_PICDESC_FAIL = APP_ERR_DVPP_BASE + 12, // DVPP: fail to create acldvppCreatePicDesc or 101 // fail to set acldvppCreatePicDesc 102 APP_ERR_DVPP_CONFIG_FAIL = APP_ERR_DVPP_BASE + 13, // DVPP: fail to set dvpp configuration,such as 103 // resize configuration,crop configuration 104 APP_ERR_DVPP_OBJ_FUNC_MISMATCH = APP_ERR_DVPP_BASE + 14, // DVPP: DvppCommon object mismatch the function 105 APP_ERR_DVPP_END, // Not an error code, define the range of common error code 106 107 // define the error code of inference 108 APP_ERR_INFER_BASE = 3000, 109 APP_ERR_INFER_SET_INPUT_FAIL = APP_ERR_INFER_BASE + 1, // Infer: set input fail 110 APP_ERR_INFER_SET_OUTPUT_FAIL = APP_ERR_INFER_BASE + 2, // Infer: set output fail 111 APP_ERR_INFER_CREATE_OUTPUT_FAIL = APP_ERR_INFER_BASE + 3, // Infer: create output fail 112 APP_ERR_INFER_OP_SET_ATTR_FAIL = APP_ERR_INFER_BASE + 4, // Infer: set op attribute fail 113 APP_ERR_INFER_GET_OUTPUT_FAIL = APP_ERR_INFER_BASE + 5, // Infer: get model output fail 114 APP_ERR_INFER_FIND_MODEL_ID_FAIL = APP_ERR_INFER_BASE + 6, // Infer: find model id fail 115 APP_ERR_INFER_FIND_MODEL_DESC_FAIL = APP_ERR_INFER_BASE + 7, // Infer: find model description fail 116 APP_ERR_INFER_FIND_MODEL_MEM_FAIL = APP_ERR_INFER_BASE + 8, // Infer: find model memory fail 117 APP_ERR_INFER_FIND_MODEL_WEIGHT_FAIL = APP_ERR_INFER_BASE + 9, // Infer: find model weight fail 118 119 APP_ERR_INFER_END, // Not an error code, define the range of inference error 120 // code 121 122 // define the error code of transmission 123 APP_ERR_TRANS_BASE = 4000, 124 125 APP_ERR_TRANS_END, // Not an error code, define the range of transmission 126 // error code 127 128 // define the error code of blocking queue 129 APP_ERR_QUEUE_BASE = 5000, 130 APP_ERR_QUEUE_EMPTY = APP_ERR_QUEUE_BASE + 1, // Queue: empty queue 131 APP_ERR_QUEUE_STOPED = APP_ERR_QUEUE_BASE + 2, // Queue: queue stoped 132 APP_ERROR_QUEUE_FULL = APP_ERR_QUEUE_BASE + 3, // Queue: full queue 133 134 // define the idrecognition web error code 135 APP_ERROR_FACE_WEB_USE_BASE = 10000, 136 APP_ERROR_FACE_WEB_USE_SYSTEM_ERROR = APP_ERROR_FACE_WEB_USE_BASE + 1, // Web: system error 137 APP_ERROR_FACE_WEB_USE_MUL_FACE = APP_ERROR_FACE_WEB_USE_BASE + 2, // Web: multiple faces 138 APP_ERROR_FACE_WEB_USE_REPEAT_REG = APP_ERROR_FACE_WEB_USE_BASE + 3, // Web: repeat registration 139 APP_ERROR_FACE_WEB_USE_PART_SUCCESS = APP_ERROR_FACE_WEB_USE_BASE + 4, // Web: partial search succeeded 140 APP_ERROR_FACE_WEB_USE_NO_FACE = APP_ERROR_FACE_WEB_USE_BASE + 5, // Web: no face detected 141 APP_ERR_QUEUE_END, // Not an error code, define the range of blocking queue 142 // error code 143 }; 144 const std::string APP_ERR_ACL_LOG_STRING[] = { 145 [APP_ERR_OK] = "Success", 146 [APP_ERR_ACL_INVALID_PARAM] = "ACL: invalid parameter", 147 [APP_ERR_ACL_BAD_ALLOC] = "ACL: memory allocation fail", 148 [APP_ERR_ACL_RT_FAILURE] = "ACL: runtime failure", 149 [APP_ERR_ACL_GE_FAILURE] = "ACL: Graph Engine failure", 150 [APP_ERR_ACL_OP_NOT_FOUND] = "ACL: operator not found", 151 [APP_ERR_ACL_OP_LOAD_FAILED] = "ACL: fail to load operator", 152 [APP_ERR_ACL_READ_MODEL_FAILURE] = "ACL: fail to read model", 153 [APP_ERR_ACL_PARSE_MODEL] = "ACL: parse model failure", 154 [APP_ERR_ACL_MODEL_MISSING_ATTR] = "ACL: model missing attribute", 155 [APP_ERR_ACL_DESERIALIZE_MODEL] = "ACL: deserialize model failure", 156 [11] = "Placeholder", 157 [APP_ERR_ACL_EVENT_NOT_READY] = "ACL: event not ready", 158 [APP_ERR_ACL_EVENT_COMPLETE] = "ACL: event complete", 159 [APP_ERR_ACL_UNSUPPORTED_DATA_TYPE] = "ACL: unsupported data type", 160 [APP_ERR_ACL_REPEAT_INITIALIZE] = "ACL: repeat initialize", 161 [APP_ERR_ACL_COMPILER_NOT_REGISTERED] = "ACL: compiler not registered", 162 [APP_ERR_ACL_IO] = "ACL: IO failed", 163 [APP_ERR_ACL_INVALID_FILE] = "ACL: invalid file", 164 [APP_ERR_ACL_INVALID_DUMP_CONFIG] = "ACL: invalid dump comfig", 165 [APP_ERR_ACL_INVALID_PROFILING_CONFIG] = "ACL: invalid profiling config", 166 [APP_ERR_ACL_OP_TYPE_NOT_MATCH] = "ACL: operator type not match", 167 [APP_ERR_ACL_OP_INPUT_NOT_MATCH] = "ACL: operator input not match", 168 [APP_ERR_ACL_OP_OUTPUT_NOT_MATCH] = "ACL: operator output not match", 169 [APP_ERR_ACL_OP_ATTR_NOT_MATCH] = "ACL: operator attribute not match", 170 [APP_ERR_ACL_API_NOT_SUPPORT] = "ACL: API not supported", 171 [APP_ERR_ACL_CREATE_DATA_BUF_FAILED] = "ACL: create data buffer fail", 172 }; 173 174 const std::string APP_ERR_COMMON_LOG_STRING[] = { 175 [0] = "Placeholder", 176 [1] = "General Failed", 177 [2] = "Internal error", 178 [3] = "Invalid Pointer", 179 [4] = "Invalid parameter", 180 [5] = "Not implemented", 181 [6] = "Out of memory", 182 [7] = "memory allocation error", 183 [8] = "free memory error", 184 [9] = "out of range", 185 [10] = "NO Permission ", 186 [11] = "Timed out", 187 [12] = "Not initialized", 188 [13] = "initialize failed", 189 [14] = "Operation now in progress ", 190 [15] = "Object, file or other resource already exist", 191 [16] = "Object, file or other resource already doesn't exist", 192 [17] = "Object, file or other resource is in use", 193 [18] = "No available Device or resource", 194 [19] = "Device, file or resource open failed", 195 [20] = "Device, file or resource read failed", 196 [21] = "Device, file or resource write failed", 197 [22] = "Device, file or resource destory failed", 198 [23] = " ", 199 [24] = "Out of connection, Communication shutdown", 200 [25] = "connection fail", 201 [26] = "ACL stream is null pointer", 202 }; 203 204 const std::string APP_ERR_DVPP_LOG_STRING[] = { 205 [0] = "Placeholder", 206 [1] = "DVPP: crop fail", 207 [2] = "DVPP: resize fail", 208 [3] = "DVPP: corp and resize fail", 209 [4] = "DVPP: convert image format fail", 210 [5] = "DVPP: VPC(crop, resize, convert format) fail", 211 [6] = "DVPP: decode jpeg or jpg fail", 212 [7] = "DVPP: encode jpeg or jpg fail", 213 [8] = "DVPP: encode png fail", 214 [9] = "DVPP: decode H264 or H265 fail", 215 [10] = "DVPP: encode H264 or H265 fail", 216 [11] = "DVPP: acldvppChannelDesc is nullptr", 217 [12] = "DVPP: fail to create or set acldvppCreatePicDesc", 218 [13] = "DVPP: fail to set dvpp configuration", 219 [14] = "DVPP: DvppCommon object mismatch the function", 220 }; 221 222 const std::string APP_ERR_INFER_LOG_STRING[] = { 223 [0] = "Placeholder", 224 [1] = "Infer: set input fail", 225 [2] = "Infer: set output fail", 226 [3] = "Infer: create output fail", 227 [4] = "Infer: set op attribute fail", 228 [5] = "Infer: get model output fail", 229 [6] = "Infer: find model id fail", 230 [7] = "Infer: find model description fail", 231 [8] = "Infer: find model memory fail", 232 [9] = "Infer: find model weight fail", 233 }; 234 235 const std::string APP_ERR_QUEUE_LOG_STRING[] = { 236 [0] = "Placeholder", 237 [1] = "empty queue", 238 [2] = "queue stoped", 239 [3] = "full queue", 240 }; 241 242 const std::string APP_ERR_FACE_LOG_STRING[] = { 243 [0] = "Placeholder", 244 [1] = "system error", 245 [2] = "multiple faces", 246 [3] = "repeat registration", 247 [4] = "partial search succeeded", 248 [5] = "no face detected", 249 }; 250 251 std::string GetAppErrCodeInfo(APP_ERROR err); 252 void AssertErrorCode(const int code, const std::string file, const std::string function, const int line); 253 void CheckErrorCode(const int code, const std::string file, const std::string function, const int line); 254 255 #define RtAssert(code) AssertErrorCode(code, __FILE__, __FUNCTION__, __LINE__); 256 #define RtCheckError(code) CheckErrorCode(code, __FILE__, __FUNCTION__, __LINE__); 257 258 #endif // ERROR_CODE_H_