diff --git a/interfaces/kits/napi/include/cm_napi_common.h b/interfaces/kits/napi/include/cm_napi_common.h index 015722cdfb569ed39e871819f8b30b64ad6da201..eaae94d03bd564451b124707ad7514fc33e9abfb 100644 --- a/interfaces/kits/napi/include/cm_napi_common.h +++ b/interfaces/kits/napi/include/cm_napi_common.h @@ -57,6 +57,9 @@ static const std::string CM_RESULT_PRPPERTY_CREDENTIAL = "credential"; static const std::string CM_CERT_SCOPE_STR = "certScope"; static const std::string CM_CERT_TYPE_STR = "certType"; +static const std::string GENERIC_MSG = "There is an internal error. Possible causes: " + "1.IPC communication failed. 2.Memory operation error."; + static const int32_t RESULT_NUMBER = 2; static const uint32_t APPLICATION_CERTIFICATE_STORE = 0; static const uint32_t APPLICATION_PRIVATE_CERTIFICATE_STORE = 3; diff --git a/interfaces/kits/napi/src/cm_napi_common.cpp b/interfaces/kits/napi/src/cm_napi_common.cpp index 4823daa1c29da71cf39b54073a06d1e77b0147a0..143938276d8450ac0e7c43a31d43a68535e3783f 100644 --- a/interfaces/kits/napi/src/cm_napi_common.cpp +++ b/interfaces/kits/napi/src/cm_napi_common.cpp @@ -28,7 +28,6 @@ constexpr int CM_MAX_DATA_LEN = 0x6400000; // The maximum length is 100M static const std::string NO_PERMISSION_MSG = "the caller has no permission"; static const std::string NOT_SYSTEM_APP_MSG = "the caller is not a system application"; static const std::string INVALID_PARAMS_MSG = "the input parameters is invalid"; -static const std::string GENERIC_MSG = "there is an internal error"; static const std::string NO_FOUND_MSG = "the certificate do not exist"; static const std::string INCORRECT_FORMAT_MSG = "the input cert data is invalid"; static const std::string MAX_CERT_COUNT_REACHED_MSG = "the count of certificates or credentials reach the max"; diff --git a/interfaces/kits/napi/src/cm_napi_get_cert_store_path.cpp b/interfaces/kits/napi/src/cm_napi_get_cert_store_path.cpp index 66b074e4d6922c6ee0169b1b46d7084a91ec5320..0677bc25de0890b3113c7cc280a356d80b3db13e 100644 --- a/interfaces/kits/napi/src/cm_napi_get_cert_store_path.cpp +++ b/interfaces/kits/napi/src/cm_napi_get_cert_store_path.cpp @@ -92,7 +92,7 @@ static napi_value GetCertStorePath(napi_env env, const enum CmCertType certType, int32_t ret = GetUserCaStorePath(certScope, path); if (ret != CM_SUCCESS) { CM_LOG_E("Failed to get user ca path."); - ThrowError(env, INNER_FAILURE, "there is an internal error"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); return nullptr; } } @@ -101,7 +101,7 @@ static napi_value GetCertStorePath(napi_env env, const enum CmCertType certType, napi_status status = napi_create_string_utf8(env, path.c_str(), path.length(), &result); if (status != napi_ok) { CM_LOG_E("Failed to creat string out."); - ThrowError(env, INNER_FAILURE, "there is an internal error"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); return nullptr; } return result; diff --git a/interfaces/kits/napi/src/cm_napi_grant.cpp b/interfaces/kits/napi/src/cm_napi_grant.cpp index cfa5854ff78965558e3cf4dc800eef2a970c493b..9eb949eb054d8fae7a93cc429511229a02e7fdc0 100644 --- a/interfaces/kits/napi/src/cm_napi_grant.cpp +++ b/interfaces/kits/napi/src/cm_napi_grant.cpp @@ -354,7 +354,7 @@ static napi_value GrantUidAsyncWork(napi_env env, GrantAsyncContext context) napi_status status = napi_queue_async_work(env, context->asyncWork); if (status != napi_ok) { - ThrowError(env, INNER_FAILURE, "queue asyncWork error"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); CM_LOG_E("get async work failed when granting uid"); return nullptr; } @@ -378,7 +378,7 @@ static napi_value RemoveUidAsyncWork(napi_env env, GrantAsyncContext context) napi_status status = napi_queue_async_work(env, context->asyncWork); if (status != napi_ok) { - ThrowError(env, INNER_FAILURE, "queue asyncWork error"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); CM_LOG_E("queue async work failed when removing uid"); return nullptr; } @@ -402,7 +402,7 @@ static napi_value IsAuthedAsyncWork(napi_env env, GrantAsyncContext context) napi_status status = napi_queue_async_work(env, context->asyncWork); if (status != napi_ok) { - ThrowError(env, INNER_FAILURE, "queue asyncWork error"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); CM_LOG_E("queue async work failed when using isAuthed"); return nullptr; } @@ -426,7 +426,7 @@ static napi_value GetUidListAsyncWork(napi_env env, GrantAsyncContext context) napi_status status = napi_queue_async_work(env, context->asyncWork); if (status != napi_ok) { - ThrowError(env, INNER_FAILURE, "queue asyncWork error"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); CM_LOG_E("queue async work failed when getting authed uid list"); return nullptr; } diff --git a/interfaces/kits/napi/src/cm_napi_sign_verify.cpp b/interfaces/kits/napi/src/cm_napi_sign_verify.cpp index a583e82e87eb189bacab211df16db40eeceb4ead..39ccfa92fcbe6b07bb2baaf062dee90449a7355f 100644 --- a/interfaces/kits/napi/src/cm_napi_sign_verify.cpp +++ b/interfaces/kits/napi/src/cm_napi_sign_verify.cpp @@ -357,7 +357,7 @@ static napi_value MallocFinishOutData(napi_env env, SignVerifyAsyncContext conte context->signature = static_cast(CmMalloc(sizeof(CmBlob))); if (context->signature == nullptr) { /* signature will free after all process */ CM_LOG_E("malloc outData failed when process sign finish"); - ThrowError(env, INNER_FAILURE, "malloc failed"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); return nullptr; } (void)memset_s(context->signature, sizeof(CmBlob), 0, sizeof(CmBlob)); @@ -365,7 +365,7 @@ static napi_value MallocFinishOutData(napi_env env, SignVerifyAsyncContext conte uint8_t *data = static_cast(CmMalloc(OUT_SIGNATURE_SIZE)); if (data == nullptr) { CM_LOG_E("malloc outData.data failed when process sign finish"); - ThrowError(env, INNER_FAILURE, "malloc failed"); + ThrowError(env, INNER_FAILURE, GENERIC_MSG); return nullptr; } (void)memset_s(data, OUT_SIGNATURE_SIZE, 0, OUT_SIGNATURE_SIZE); diff --git a/interfaces/kits/napi/src/dialog/cm_napi_dialog_common.cpp b/interfaces/kits/napi/src/dialog/cm_napi_dialog_common.cpp index 2635285d65b511f1ebea505f0a4737b30a8aa361..5379a165817a3da9a18062d7072320fcfdd51bdf 100644 --- a/interfaces/kits/napi/src/dialog/cm_napi_dialog_common.cpp +++ b/interfaces/kits/napi/src/dialog/cm_napi_dialog_common.cpp @@ -48,7 +48,8 @@ constexpr int CM_MAX_DATA_LEN = 0x6400000; // The maximum length is 100M static const std::string DIALOG_NO_PERMISSION_MSG = "the caller has no permission"; static const std::string DIALOG_INVALID_PARAMS_MSG = "the input parameters is invalid"; -static const std::string DIALOG_GENERIC_MSG = "there is an internal error"; +static const std::string DIALOG_GENERIC_MSG = "There is an internal error. Possible causes: " + "1.IPC communication failed. 2.Memory operation error."; static const std::string DIALOG_OPERATION_CANCELS_MSG = "the user cancels the installation operation"; static const std::string DIALOG_INSTALL_FAILED_MSG = "the user install certificate failed" " in the certificate manager dialog";