1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 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 DRIVE_KIT_ERROR_H 17 #define DRIVE_KIT_ERROR_H 18 19 #include <iostream> 20 #include <vector> 21 22 namespace DriveKit { 23 enum class DKLocalErrorCode { 24 NO_ERROR = 0, 25 IPC_CONNECT_FAILED, 26 IPC_SEND_FAILED, 27 DATA_TYPE_ERROR, 28 ACCESS_DENIED, 29 ATOMIC_ERROR, 30 AUTHENTICATION_FAILED, 31 AUTHENTICATION_REQUIRED, 32 BAD_REQUEST, 33 CONFLICT, 34 EXISTS, 35 INTERNAL_ERROR, 36 NOT_FOUND, 37 QUOTA_EXCEEDED, 38 SIGN_IN_FAILED, 39 THROTTLED, 40 TRY_AGAIN_LATER, 41 VALIDATING_REFERENCE_ERROR, 42 UNIQUE_FIELD_ERROR, 43 ZONE_NOT_FOUND, 44 UNKNOWN_ERROR, 45 NETWORK_ERROR, 46 SERVICE_UNAVAILABLE, 47 INVALID_ARGUMENTS, 48 UNEXPECTED_SERVER_RESPONSE, 49 CONFIGURATION_ERROR, 50 SHARE_UI_TIMEOUT, 51 BAD_ALLOC_MEMORY, 52 }; 53 54 enum class DKServerErrorCode { 55 ACCESS_DENIED = 403, 56 ATOMIC_ERROR = 400, 57 AUTHENTICATION_FAILED = 401, 58 AUTHENTICATION_REQUIRED = 421, 59 BAD_REQUEST = 400, 60 CONFLICT = 409, 61 EXISTS = 409, 62 INTERNAL_ERROR = 500, 63 NOT_FOUND = 404, 64 QUOTA_EXCEEDED = 413, 65 THROTTLED = 429, 66 TRY_AGAIN_LATER = 503, 67 VALIDATING_REFERENCE_ERROR = 412, 68 ZONE_NOT_FOUND = 404, 69 NETWORK_ERROR = 1008, 70 }; 71 72 enum class DKDetailErrorCode { 73 LACK_OF_PARAM = 4001, //缺少入参 74 PARAM_INVALID = 4002, //参数校验失败 75 PARAM_VALUE_NOT_SUPPORT = 4003, //参数不支持 76 PARAM_EXPIRED = 4004, //入参已失效 77 SITE_NOT_FOUND = 4005, //站点信息未知 78 NON_SUPPORT_CHARACTER_INCLUDED = 4006, //包含有不支持的字符 79 ILLEGAL_CHARACTER_INCLUDED = 4007, //包含有非法的字符 80 PARAMETER_LENGTH_BEYOND_LIMIT = 4008, //参数长度超过限制 81 PARENTFOLDER_NOT_FOUND = 4009, //父目录不在 82 TOKEN_CFG_INVALID = 4010, //token配置项无效 83 USER_NOT_AUTHORIZED = 4011, //用户没有授权 84 APP_NOT_AUTHORIZED = 4012, //App没有授权 85 TICKET_INVALID = 4013, //ticket无效 86 GRANT_CANCEL = 4014, //取消授权 87 LOGIN_FAILED = 4015, //登录失败 88 SESSION_TIMEOUT = 4016, //会话过期 89 FORCE_RELOGIN = 4017, //强制重新登录账号 90 FLOE_ID_NOT_MATCH = 4020, //越权 91 DATA_MIGRATING = 4031, //数据割接未完成 92 SERVICE_NOT_SUPPORT = 4032, //服务未开放 93 AGREEMENT_NOT_SIGNED = 4033, //协议未签署 94 CROSS_SITE_NOT_SUPPORT = 4034, //跨站点功能限制 95 INSUFFICIENT_SCOPE = 4035, //Scope校验失败 96 INSUFFICIENT_PERMISSION = 4036, //无此操作权限 97 OPERATION_NOT_COMPLETE = 4037, //由于错误无法完成操作 98 OUTER_SERVICE_ERROR = 4038, //外部服务错误且无法恢复 99 SPACE_FULL = 4039, //用户空间不足 100 CONTENT_NOT_FIND = 4041, //内容未发现 101 CONTENT_UNAVAILABLE = 4042, //内容解析失败 102 CHANNEL_NOT_FOUND = 4043, //订阅未发现 103 THUMBNALL_NOT_FOUND = 4044, //缩略图不存在 104 SHARE_LINK_NOT_FOUND = 4045, //分享链接不存在 105 TEMP_DATA_INVALID = 4046, //临时数据无效 106 FILE_NOT_FOUND = 4047, //实体数据不存在 107 APP_NOT_EXISTS = 4048, //APP不存在 108 CATAGORY_NOT_EXISTS = 4049, //分类不存在 109 SHARE_CONTENT_NOE_EXISTS = 4050, //分享内容不存在 110 THUMBNALL_GENERATE_FAILED = 4051, //缩略图生成失败 111 VERSION_CONFLICT = 4090, //版本冲突 112 LOCK_FAILED = 4091, //获取锁失败 113 SILENCE_USER_FAILED = 4092, //沉默用户拒绝失败 114 FILE_USING_FORBIDDEN_OP = 4093, //文件正在使用禁止操作 115 CURSOR_EXPIRED = 4100, //游标过期 116 TEMP_DATA_CLEARD = 4101, //临时数据已经被清理 117 CLOUD_DATA_UPDATED = 4121, //云端数据已被更新 118 USER_REQUEST_TOO_MANY = 4291, //用户请求太频繁 119 APP_REQUEST_TOO_MANY = 4292, //应用请求太频繁 120 FLOW_CONTROL = 4293, //用户请求流控 121 USER_REQUEST_ERROR_TOO_MANY = 4294, //用户请求错误次数超过限制 122 PARTIAL_FILE_NOT_SUPPORT_SHARE = 4905, //部分文件不支持分享 123 PARENTFOLDER_TRASHED = 4906, //父目录被删除到回收站 124 ACCOUNT_NAME_WRONG = 4907, //用户账号错误 125 CIPHER_INVALID = 4908, //用户秘钥已经失效 126 DUPLICATED_ID = 4909, //id已存在 127 VUDID_IMEI_INVALID = 4910, //VUDID转换IMEI失败 128 FILE_NOT_SUPPORT_SHARE = 4911, //所有文件不支持分享 129 EXTERNAL_LINK_NOT_AUTHORIZED = 4912, //外部链接没有授权 130 ORIGINAL_NOT_EXIST = 4913, //源文件不存在 131 ABNORMAL_DOWNLOAD = 4931, //用户异常下载 132 SAME_FILENAME_NOT_ALLOWED = 4932, //禁止重复文件名 133 CANNOT_USE_SERVICE = 4933, //无法为此用户提供服务 134 FILES_NUM_BEYOND_LIMIT = 4934, //下载文件数超过限制 135 FILES_SIZE_BEYOND_LIMIT = 4935, //下载文件大小超过限制 136 TIER_BEYOND_LIMIT = 4936, //层级超过限制 137 HISTORYVERSIONS_BEYOND_LIMIT = 4937, //历史版本数超过限制 138 COPY_FORBIDDEN = 4938, //此文件禁止拷贝 139 USER_SUSPEND_SERVICE = 4939, //用户停用服务 140 FILE_VERSION_CONFLICT = 4940, //文件版本冲突 141 REAL_NAME_AUTHENTCATION_FAILED = 4941, //实名认证失败 142 SHARE_LINK_EXPIRED = 4942, //分享链接已过期 143 RECEIVER_BEYOND_LIMIT = 4943, //分享人数达到限制 144 CONTENT_SHARE_NOT_ALLOWED = 4944, //内容禁止分享 145 DATA_NUMBER_BEYOND_LIMIT = 4945, //云端数据超过限制 146 FORBIDDEN_USER = 4946, //禁止用户操作 147 PARAM_CAN_NOT_UPDATE = 4947, //参数禁止更新 148 HORIZONTAL_PRIVILEGE_ESCALATION = 4948, //存在横向越权 149 OPERATION_FORBIDDEN_IN_RECYCLE = 4949, //禁止在回收站进行此操作 150 FILENAME_LENGTH_BEYOND_LIMIT = 4950, //文件名超过上限 151 OPERATION_FORBIDDEN_DELETE_BACKUP_EXIST = 4951, //禁止删除操作,存在clearTime内的备份记录 152 TEMP_KEY_EXPIRED = 4952, //临时秘钥已过期 153 USER_SHARE_NOT_ALLOWED = 4953, //用户被封禁,禁止分享 154 USER_SHARE_PRIVILEGE_LIMITED = 4954, //用户没有权益 155 CONTENT_COPYRIGHT_LIMIT = 4955, //版权文件禁止下载 156 RISK_MANAGE_FAILED = 4956, //风控失败 157 TASK_RUNNING = 4959, //任务正在执行 158 SERVER_VERSION_UNAVAILABLE = 4960, //服务版本号不可用 159 APP_STATUS_ABNORMAL = 4961, //APP状态不正常 160 CATEGORY_STATUS_ABNORMAL = 4962, //分类状态不正常 161 CATEGORY_APP_ASSOCIATIONS_EXISTS = 4963, //存在应用和分类关系 162 FUNCTION_NOT_SUPPORT = 4964, //功能暂不支持 163 MEMBER_KINSHIP_EXISTS = 4965, //成员关系已存在 164 MEMBER_NUMBER_LIMIT = 4966, //成员人数已达上限 165 USER_IS_JOINED = 4967, //用户已经加入群组 166 USER_BE_FROZEN = 4968, //用户被冻结 167 INVITER_LINK_EXPIRED = 4969, //邀请码或链接已过期 168 RISK_SCANNING = 4970, //分享内容审核中禁止访问 169 ALBUM_APPLICATION_NUMBER_LIMIT = 4971, //共享相册申请加入次数超过上限 170 INVITE_CODE_ERROR = 4972, //邀请码错误 171 INVITER_LINK_USED = 4973, //邀请码或链接已使用过 172 APPLICANT_IS_EXIST = 4974, //记录已存在 173 APPLICANT_NOT_FOUND = 4975, //记录不存在 174 APPLICANT_IS_EXPIRED = 4976, //记录已失效 175 DATA_CLEARED_FORBIDDEN = 4977, //云侧数据清理禁止访问 176 APPEAL_ACCOUNT_FORBIDDEN = 4978, //人工封禁不支持申诉 177 APPLICANT_IS_PROCESSED = 4979, //申请已经处理过 178 RESOURCE_NOT_MATCH = 4980, //备份记录资源归属不匹配 179 RISKFILE_FORBIDDEN_DOWN = 4981, //文件违规下载 180 CONTENT_IS_EXPIRED = 4982, //内容已过期 181 BATCH_IS_EXPIRED = 4983, //批次失效 182 USER_NOT_REALNAME = 4984, //用户未实名认证 183 SERVER_IS_BUSY = 5001, //服务器资源不够 184 OUTER_SERVICE_UNAVAILABLE = 5002, //外部服务不可用 185 OUTER_SERVICE_BUSY = 5003, //外部服务忙 186 DATABASE_UNAVAILABLE = 5004, //数据库操作失败 187 RESOURCE_LOCKED = 5005, //资源被锁住,暂时禁止操作 188 SERVER_TEMP_ERROR = 5006, //服务器临时错误 189 SERVER_UPDATING = 5007, //服务器升级中 190 RESOURCE_TRASHING = 5008, //资源GC中,暂时禁止操作 191 SERVICE_UNAVAILABLE = 5030, //服务不可用 192 NSP_FLOW_CONTROL = 5031, //NSP_FLOW_CONTROL 193 TEMP_ERROR_RETRY = 5040, //触发端侧重试错误码 194 }; 195 196 struct DKErrorDetail { 197 std::string domain; 198 std::string reason; 199 std::string errorCode; 200 std::string description; 201 std::string errorPos; 202 std::string errorParam; 203 int detailCode; 204 }; 205 206 class DKError { 207 public: 208 bool HasError() const; 209 void SetLocalError(DKLocalErrorCode code); 210 void SetServerError(int code); 211 212 bool isLocalError = false; 213 DKLocalErrorCode dkErrorCode; 214 bool isServerError = false; 215 int serverErrorCode; 216 std::string reason; 217 std::vector<DKErrorDetail> errorDetails; 218 int retryAfter; 219 }; 220 } // namespace DriveKit 221 #endif 222