From ec53fa9129bdbdc9590f8a45bb33c555dce3fdb6 Mon Sep 17 00:00:00 2001 From: li-li-wang Date: Sat, 12 Aug 2023 14:14:01 +0800 Subject: [PATCH] Description:fix error code Match-id-451bcfa54b7eec1b243e495cd377ad671f0a8bef --- entry/src/main/ets/common/constant.ets | 3 +++ entry/src/main/ets/common/utils.ets | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/entry/src/main/ets/common/constant.ets b/entry/src/main/ets/common/constant.ets index 8c4d780..4a0bbbe 100644 --- a/entry/src/main/ets/common/constant.ets +++ b/entry/src/main/ets/common/constant.ets @@ -125,9 +125,12 @@ export default class Constants { static ERR_JS_APP_PARAM_ERROR = 4; static ERR_JS_APP_GET_FILE_ASSET_ERROR = 5; static ERR_JS_CREDENTIAL_TIMEOUT = 19100003; + static ERR_JS_CREDENTIAL_SERVICE_ERROR = 19100004; static ERR_JS_CREDENTIAL_SERVER_ERROR = 19100005; static ERR_JS_NOT_DLP_FILE = 19100008; static ERR_JS_DLP_FILE_READ_ONLY = 19100010; + static ERR_JS_USER_NO_PERMISSION = 19100013; + static ERR_JS_ACCOUNT_NOT_LOGIN = 19100014; static ERR_JS_INVALID_PARAMETER = 12300002; static ERR_JS_ACCOUNT_NOT_FOUND = 12300003; static DLP_FILE_PARSE_ERROR = 103; diff --git a/entry/src/main/ets/common/utils.ets b/entry/src/main/ets/common/utils.ets index b6a4f77..61ec156 100644 --- a/entry/src/main/ets/common/utils.ets +++ b/entry/src/main/ets/common/utils.ets @@ -102,16 +102,24 @@ function terminateSelfWithResult(resultCode: number, result: string): void { function getAlertMessage(err, defaultTitle?: Resource, defaultMessage?: Resource) { switch (err.code) { + case Constants.ERR_JS_USER_NO_PERMISSION: + return { + 'title': $r('app.string.TITLE_APP_VISIT_FILE_ERROR'), + 'msg': $r('app.string.MESSAGE_APP_NOT_HAVE_PERM_VISIT', err.extra) + } case Constants.ERR_JS_APP_INSIDE_ERROR: return { 'title': $r('app.string.TITLE_APP_ERROR'), 'msg': $r('app.string.MESSAGE_APP_INSIDE_ERROR') }; case Constants.ERR_JS_GET_ACCOUNT_ERROR: return { 'title': $r('app.string.TITLE_APP_ERROR'), 'msg': $r('app.string.MESSAGE_APP_GET_ACCOUNT_ERROR') }; case Constants.ERR_JS_APP_NO_ACCOUNT_ERROR: + case Constants.ERR_JS_ACCOUNT_NOT_LOGIN: return { 'title': $r('app.string.TITLE_APP_ERROR'), 'msg': $r('app.string.MESSAGE_APP_NO_ACCOUNT_ERROR') }; case Constants.ERR_JS_APP_PARAM_ERROR: return { 'title': $r('app.string.TITLE_APP_ERROR'), 'msg': $r('app.string.MESSAGE_APP_PARAM_ERROR') }; case Constants.ERR_JS_APP_GET_FILE_ASSET_ERROR: return { 'title': $r('app.string.TITLE_APP_ERROR'), 'msg': $r('app.string.MESSAGE_APP_GET_FILE_ASSET_ERROR') }; + case Constants.ERR_JS_CREDENTIAL_SERVICE_ERROR: + return { 'title': $r('app.string.TITLE_SERVICE_ERROR'), 'msg': $r('app.string.MESSAGE_SERVICE_INSIDE_ERROR') }; case Constants.ERR_JS_CREDENTIAL_SERVER_ERROR: return { 'title': $r('app.string.TITLE_SERVICE_ERROR'), 'msg': $r('app.string.MESSAGE_DLP_CREDENTIAL_SERVER_ERROR') }; case Constants.ERR_JS_NOT_DLP_FILE: @@ -121,12 +129,7 @@ function getAlertMessage(err, defaultTitle?: Resource, defaultMessage?: Resource case Constants.ERR_JS_DLP_FILE_READ_ONLY: return { 'title': $r('app.string.TITLE_OPERATE_DENY'), 'msg': $r('app.string.MESSAGE_DLP_READ_ONLY') }; default: - if (err.extra != undefined) { // has contact account - return { - 'title': $r('app.string.TITLE_APP_VISIT_FILE_ERROR'), - 'msg': $r('app.string.MESSAGE_APP_NOT_HAVE_PERM_VISIT', err.extra) - } - } else if (defaultTitle !== undefined && defaultMessage != undefined) { + if (defaultTitle !== undefined && defaultMessage != undefined) { return { 'title': defaultTitle, 'msg': defaultMessage }; } else { return { 'title': $r('app.string.TITLE_APP_ERROR'), 'msg': $r('app.string.MESSAGE_APP_INSIDE_ERROR') };