修改ThrowParamsError为ThrowError

Signed-off-by: 陈怡博 <chenyibo6@huawei.com>
This commit is contained in:
陈怡博 2024-05-07 20:52:41 +08:00
parent b338dc191e
commit d7a7012f63
13 changed files with 78 additions and 78 deletions

View File

@ -79,7 +79,7 @@ napi_value GenerateCredentialAbstractArray(napi_env env,
napi_value GenerateCertInfo(napi_env env, const struct CertInfo *certInfo);
napi_value GenerateAppCertInfo(napi_env env, const struct Credential *credential);
void ThrowParamsError(napi_env env, int32_t errorCode, std::string errMsg);
void ThrowError(napi_env env, int32_t errorCode, std::string errMsg);
napi_value GenerateBusinessError(napi_env env, int32_t errorCode, const char *errorMsg);
void DeleteNapiContext(napi_env env, napi_async_work &asyncWork, napi_ref &callback);

View File

@ -376,7 +376,7 @@ napi_value GenerateBusinessError(napi_env env, int32_t errorCode, const char *er
return businessError;
}
void ThrowParamsError(napi_env env, int32_t errorCode, std::string errMsg)
void ThrowError(napi_env env, int32_t errorCode, std::string errMsg)
{
napi_value paramsError = nullptr;
napi_value code = nullptr;

View File

@ -68,7 +68,7 @@ napi_value GetAppCertInfoParseParams(
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_GET_APP_CERT_INFO_MIN_ARGS) && (argc != CM_NAPI_GET_APP_CERT_INFO_MAX_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 1 and 2.");
ThrowError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 1 and 2.");
CM_LOG_E("arguments count invalid. argc = %d", argc);
return nullptr;
}
@ -76,7 +76,7 @@ napi_value GetAppCertInfoParseParams(
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->keyUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "keyUri is not a string or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "keyUri is not a string or the length is 0 or too long.");
CM_LOG_E("could not get key uri");
return nullptr;
}
@ -85,7 +85,7 @@ napi_value GetAppCertInfoParseParams(
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function faild when getting application cert info");
return nullptr;
}

View File

@ -64,7 +64,7 @@ napi_value GetAppCertListParseParams(
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_GET_APP_CERT_LIST_MIN_ARGS) && (argc != CM_NAPI_GET_APP_CERT_LIST_MAX_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "Missing parameter, arguments count need between 0 and 1.");
ThrowError(env, PARAM_ERROR, "Missing parameter, arguments count need between 0 and 1.");
CM_LOG_E("Missing parameter");
return nullptr;
}
@ -73,7 +73,7 @@ napi_value GetAppCertListParseParams(
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function faild when getting application certificate list");
return nullptr;
}

View File

@ -80,7 +80,7 @@ static napi_value GetCertInfoParseParams(napi_env env, napi_callback_info info,
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_GET_CERT_INFO_MAX_ARGS) && (argc != CM_NAPI_GET_CERT_INFO_MIN_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid when getting trusted certificate info");
ThrowError(env, PARAM_ERROR, "arguments count invalid when getting trusted certificate info");
CM_LOG_E("arguments count invalid when getting trusted certificate info");
return nullptr;
}
@ -88,7 +88,7 @@ static napi_value GetCertInfoParseParams(napi_env env, napi_callback_info info,
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->certUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "certUri type error");
ThrowError(env, PARAM_ERROR, "certUri type error");
CM_LOG_E("get cert uri failed when getting trusted certificate info");
return nullptr;
}
@ -97,7 +97,7 @@ static napi_value GetCertInfoParseParams(napi_env env, napi_callback_info info,
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when get cert info function");
return nullptr;
}

View File

@ -76,7 +76,7 @@ static napi_value GetCertListParseParams( napi_env env, napi_callback_info in
if ((argc != CM_NAPI_GET_CERT_LIST_MIN_ARGS) &&
(argc != CM_NAPI_GET_CERT_LIST_MAX_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid when getting trusted certificate list");
ThrowError(env, PARAM_ERROR, "arguments count invalid when getting trusted certificate list");
CM_LOG_E("arguments count is not expected when getting trusted certificate list");
return nullptr;
}
@ -85,7 +85,7 @@ static napi_value GetCertListParseParams( napi_env env, napi_callback_info in
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when get certlist function");
return nullptr;
}

View File

@ -98,7 +98,7 @@ static napi_value ParseGrantUidParams(napi_env env, napi_callback_info info, Gra
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_GRANT_ARGS_CNT) && (argc != (CM_NAPI_GRANT_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid when grant or remove uid");
ThrowError(env, PARAM_ERROR, "arguments count invalid when grant or remove uid");
CM_LOG_E("arguments count is not expected when grant or remove uid");
return nullptr;
}
@ -106,7 +106,7 @@ static napi_value ParseGrantUidParams(napi_env env, napi_callback_info info, Gra
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->keyUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "keyUri type error");
ThrowError(env, PARAM_ERROR, "keyUri type error");
CM_LOG_E("get uri failed when grant or remove uid");
return nullptr;
}
@ -114,7 +114,7 @@ static napi_value ParseGrantUidParams(napi_env env, napi_callback_info info, Gra
index++;
result = ParseString2Uint32(env, argv[index], context->appUid);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "appUid type error");
ThrowError(env, PARAM_ERROR, "appUid type error");
CM_LOG_E("get app uid failed when grant or remove uid ");
return nullptr;
}
@ -123,7 +123,7 @@ static napi_value ParseGrantUidParams(napi_env env, napi_callback_info info, Gra
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when grant or remove uid");
return nullptr;
}
@ -144,7 +144,7 @@ static napi_value ParseIsAuthedParams(napi_env env, napi_callback_info info, Gra
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_IS_AUTHED_ARGS_CNT) && (argc != (CM_NAPI_IS_AUTHED_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 1 and 2.");
ThrowError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 1 and 2.");
CM_LOG_E("arguments count is not expected when using isAuthed");
return nullptr;
}
@ -152,7 +152,7 @@ static napi_value ParseIsAuthedParams(napi_env env, napi_callback_info info, Gra
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->keyUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "keyUri is not a string or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "keyUri is not a string or the length is 0 or too long.");
CM_LOG_E("get uri failed when using isAuthed");
return nullptr;
}
@ -161,7 +161,7 @@ static napi_value ParseIsAuthedParams(napi_env env, napi_callback_info info, Gra
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function failed when using isAuthed");
return nullptr;
}
@ -353,7 +353,7 @@ static napi_value GrantUidAsyncWork(napi_env env, GrantAsyncContext context)
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, INNER_FAILURE, "queue asyncWork error");
ThrowError(env, INNER_FAILURE, "queue asyncWork error");
CM_LOG_E("get async work failed when granting uid");
return nullptr;
}
@ -377,7 +377,7 @@ static napi_value RemoveUidAsyncWork(napi_env env, GrantAsyncContext context)
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, INNER_FAILURE, "queue asyncWork error");
ThrowError(env, INNER_FAILURE, "queue asyncWork error");
CM_LOG_E("queue async work failed when removing uid");
return nullptr;
}
@ -401,7 +401,7 @@ static napi_value IsAuthedAsyncWork(napi_env env, GrantAsyncContext context)
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, INNER_FAILURE, "queue asyncWork error");
ThrowError(env, INNER_FAILURE, "queue asyncWork error");
CM_LOG_E("queue async work failed when using isAuthed");
return nullptr;
}
@ -425,7 +425,7 @@ static napi_value GetUidListAsyncWork(napi_env env, GrantAsyncContext context)
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, INNER_FAILURE, "queue asyncWork error");
ThrowError(env, INNER_FAILURE, "queue asyncWork error");
CM_LOG_E("queue async work failed when getting authed uid list");
return nullptr;
}

View File

@ -76,7 +76,7 @@ napi_value InstallAppCertParseParams(
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_INSTALL_APP_CERT_MIN_ARGS) && (argc != CM_NAPI_INSTALL_APP_CERT_MAX_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 3 and 4.");
ThrowError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 3 and 4.");
CM_LOG_E("arguments count invalid. argc = %d", argc);
return nullptr;
}
@ -91,7 +91,7 @@ napi_value InstallAppCertParseParams(
napi_value result = GetUint8Array(env, argv[index], *context->keystore);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "keystore is not a uint8Array or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "keystore is not a uint8Array or the length is 0 or too long.");
CM_LOG_E("could not get keystore");
return nullptr;
}
@ -99,7 +99,7 @@ napi_value InstallAppCertParseParams(
index++;
result = ParseString(env, argv[index], context->keystorePwd);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "keystore Pwd is not a string or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "keystore Pwd is not a string or the length is 0 or too long.");
CM_LOG_E("could not get keystore Pwd");
return nullptr;
}
@ -107,7 +107,7 @@ napi_value InstallAppCertParseParams(
index++;
result = ParseString(env, argv[index], context->keyAlias);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "keyAlias is not a string or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "keyAlias is not a string or the length is 0 or too long.");
CM_LOG_E("could not get uri");
return nullptr;
}
@ -116,7 +116,7 @@ napi_value InstallAppCertParseParams(
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function faild when install application cert");
return nullptr;
}

View File

@ -76,7 +76,7 @@ static napi_value SetCertStatusParseParams(
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_SET_CERT_STATUS_MIN_ARGS) && (argc != CM_NAPI_SET_CERT_STATUS_MAX_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid.");
ThrowError(env, PARAM_ERROR, "arguments count invalid.");
CM_LOG_E("arguments count invalid. argc = %d", argc);
return nullptr;
}
@ -84,7 +84,7 @@ static napi_value SetCertStatusParseParams(
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->certUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "get certUri type error");
ThrowError(env, PARAM_ERROR, "get certUri type error");
CM_LOG_E("could not get cert uri when set cert status");
return nullptr;
}
@ -92,7 +92,7 @@ static napi_value SetCertStatusParseParams(
index++;
result = ParseUint32(env, argv[index], context->store);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "get store type error");
ThrowError(env, PARAM_ERROR, "get store type error");
CM_LOG_E("could not get store");
return nullptr;
}
@ -100,7 +100,7 @@ static napi_value SetCertStatusParseParams(
index++;
result = ParseBoolean(env, argv[index], context->status);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "get status type error");
ThrowError(env, PARAM_ERROR, "get status type error");
CM_LOG_E("could not get status");
return nullptr;
}
@ -109,7 +109,7 @@ static napi_value SetCertStatusParseParams(
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when set cert status function");
return nullptr;
}

View File

@ -120,7 +120,7 @@ static napi_value GetPadding(napi_env env, napi_value object, uint32_t *paddingR
}
if (type != napi_number) {
ThrowParamsError(env, PARAM_ERROR, "arguments invalid, type of param padding is not number");
ThrowError(env, PARAM_ERROR, "arguments invalid, type of param padding is not number");
CM_LOG_E("arguments invalid, type of param padding is not number");
return nullptr;
}
@ -129,7 +129,7 @@ static napi_value GetPadding(napi_env env, napi_value object, uint32_t *paddingR
status = napi_get_value_uint32(env, padding, &paddingValue);
if (status != napi_ok) {
CM_LOG_E("get padding value failed");
ThrowParamsError(env, PARAM_ERROR, "arguments invalid, get padding value failed");
ThrowError(env, PARAM_ERROR, "arguments invalid, get padding value failed");
return nullptr;
}
@ -142,7 +142,7 @@ static napi_value GetPadding(napi_env env, napi_value object, uint32_t *paddingR
}
}
if (!findFlag) {
ThrowParamsError(env, PARAM_ERROR, "padding do not exist in PADDING_MAP");
ThrowError(env, PARAM_ERROR, "padding do not exist in PADDING_MAP");
CM_LOG_E("padding do not exist in PADDING_MAP.");
return nullptr;
}
@ -167,7 +167,7 @@ static napi_value GetDigest(napi_env env, napi_value object, uint32_t *digestRet
}
if (type != napi_number) {
ThrowParamsError(env, PARAM_ERROR, "arguments invalid, type of param digest is not number");
ThrowError(env, PARAM_ERROR, "arguments invalid, type of param digest is not number");
CM_LOG_E("arguments invalid, type of param digest is not number.");
return nullptr;
}
@ -175,7 +175,7 @@ static napi_value GetDigest(napi_env env, napi_value object, uint32_t *digestRet
uint32_t digestValue = 0;
status = napi_get_value_uint32(env, digest, &digestValue);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "arguments invalid, get digest value failed");
ThrowError(env, PARAM_ERROR, "arguments invalid, get digest value failed");
CM_LOG_E("arguments invalid,get digest value failed.");
return nullptr;
}
@ -188,7 +188,7 @@ static napi_value GetDigest(napi_env env, napi_value object, uint32_t *digestRet
}
}
if (!findFlag) {
ThrowParamsError(env, PARAM_ERROR, "digest do not exist in DIGEST_MAP");
ThrowError(env, PARAM_ERROR, "digest do not exist in DIGEST_MAP");
CM_LOG_E("digest do not exist in DIGEST_MAP.");
return nullptr;
}
@ -276,7 +276,7 @@ static napi_value ParseCMInitParams(napi_env env, napi_callback_info info, SignV
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_INIT_ARGS_CNT) && (argc != (CM_NAPI_INIT_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "init arguments count invalid, arguments count need between 2 and 3.");
ThrowError(env, PARAM_ERROR, "init arguments count invalid, arguments count need between 2 and 3.");
CM_LOG_E("init arguments count is not expected");
return nullptr;
}
@ -284,7 +284,7 @@ static napi_value ParseCMInitParams(napi_env env, napi_callback_info info, SignV
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->authUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "authUri is not a string or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "authUri is not a string or the length is 0 or too long.");
CM_LOG_E("get uri failed when using init function");
return nullptr;
}
@ -292,7 +292,7 @@ static napi_value ParseCMInitParams(napi_env env, napi_callback_info info, SignV
index++;
result = ParseSpec(env, argv[index], context->spec);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "get spec type error");
ThrowError(env, PARAM_ERROR, "get spec type error");
CM_LOG_E("get sepc failed when using init function");
return nullptr;
}
@ -301,7 +301,7 @@ static napi_value ParseCMInitParams(napi_env env, napi_callback_info info, SignV
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function failed when using init function");
return nullptr;
}
@ -317,7 +317,7 @@ static napi_value ParseCMUpdateParams(napi_env env, napi_callback_info info, Sig
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_UPDATE_ARGS_CNT) && (argc != (CM_NAPI_UPDATE_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "update arguments count invalid, arguments count need between 2 and 3.");
ThrowError(env, PARAM_ERROR, "update arguments count invalid, arguments count need between 2 and 3.");
CM_LOG_E("update arguments count is not expected");
return nullptr;
}
@ -325,7 +325,7 @@ static napi_value ParseCMUpdateParams(napi_env env, napi_callback_info info, Sig
size_t index = 0;
napi_value result = GetBlob(env, argv[index], context->handle);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "handle is not a uint8Array or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "handle is not a uint8Array or the length is 0 or too long.");
CM_LOG_E("get handle failed when using update function");
return nullptr;
}
@ -333,7 +333,7 @@ static napi_value ParseCMUpdateParams(napi_env env, napi_callback_info info, Sig
index++;
result = GetBlob(env, argv[index], context->inData);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "inData is not a uint8Array or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "inData is not a uint8Array or the length is 0 or too long.");
CM_LOG_E("get inData failed when using update function");
return nullptr;
}
@ -342,7 +342,7 @@ static napi_value ParseCMUpdateParams(napi_env env, napi_callback_info info, Sig
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function failed when using update function");
return nullptr;
}
@ -356,7 +356,7 @@ static napi_value MallocFinishOutData(napi_env env, SignVerifyAsyncContext conte
context->signature = static_cast<CmBlob *>(CmMalloc(sizeof(CmBlob)));
if (context->signature == nullptr) { /* signature will free after all process */
CM_LOG_E("malloc outData failed when process sign finish");
ThrowParamsError(env, INNER_FAILURE, "malloc failed");
ThrowError(env, INNER_FAILURE, "malloc failed");
return nullptr;
}
(void)memset_s(context->signature, sizeof(CmBlob), 0, sizeof(CmBlob));
@ -364,7 +364,7 @@ static napi_value MallocFinishOutData(napi_env env, SignVerifyAsyncContext conte
uint8_t *data = static_cast<uint8_t *>(CmMalloc(OUT_SIGNATURE_SIZE));
if (data == nullptr) {
CM_LOG_E("malloc outData.data failed when process sign finish");
ThrowParamsError(env, INNER_FAILURE, "malloc failed");
ThrowError(env, INNER_FAILURE, "malloc failed");
return nullptr;
}
(void)memset_s(data, OUT_SIGNATURE_SIZE, 0, OUT_SIGNATURE_SIZE);
@ -426,7 +426,7 @@ static napi_value ProcessFinishTwoParam(napi_env env, napi_value *argv, SignVeri
ret = GetCallback(env, argv[curIndex], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("arg2 is callback: get sign callback function failed when using finish function");
return nullptr;
}
@ -438,7 +438,7 @@ static napi_value ProcessFinishTwoParam(napi_env env, napi_value *argv, SignVeri
context->isSign = false;
result = GetBlob(env, argv[curIndex], context->signature);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "signature is not a uint8Array or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "signature is not a uint8Array or the length is 0 or too long.");
CM_LOG_E("get signature failed when process promise verify");
return nullptr;
}
@ -459,7 +459,7 @@ static napi_value ProcessFinishThreeParam(napi_env env, napi_value *argv, SignVe
napi_value result = GetBlob(env, argv[curIndex], context->signature);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "signature is not a uint8Array or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "signature is not a uint8Array or the length is 0 or too long.");
CM_LOG_E("get signature failed when process callback verify");
return nullptr;
}
@ -471,7 +471,7 @@ static napi_value ProcessFinishThreeParam(napi_env env, napi_value *argv, SignVe
int32_t ret = GetCallback(env, argv[curIndex], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get verify callback function failed when using finish function");
return nullptr;
}
@ -487,7 +487,7 @@ static napi_value ParseCMFinishParams(napi_env env, napi_callback_info info, Sig
if ((argc != CM_NAPI_FINISH_ARGS_CNT) && (argc != (CM_NAPI_FINISH_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT)) &&
(argc != (CM_NAPI_FINISH_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT - CM_NAPI_SIGNATURE_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "finish arguments count invalid, arguments count need between 1 and 3.");
ThrowError(env, PARAM_ERROR, "finish arguments count invalid, arguments count need between 1 and 3.");
CM_LOG_E("finish arguments count is not expected");
return nullptr;
}
@ -495,7 +495,7 @@ static napi_value ParseCMFinishParams(napi_env env, napi_callback_info info, Sig
size_t index = 0;
napi_value result = GetBlob(env, argv[index], context->handle);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "handle is not a uint8Array or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "handle is not a uint8Array or the length is 0 or too long.");
CM_LOG_E("get handle failed when using finish function");
return nullptr;
}
@ -517,7 +517,7 @@ static napi_value ParseCMAbortParams(napi_env env, napi_callback_info info, Sign
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_ABORT_ARGS_CNT) && (argc != (CM_NAPI_ABORT_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "abort arguments count invalid, arguments count need between 1 and 2.");
ThrowError(env, PARAM_ERROR, "abort arguments count invalid, arguments count need between 1 and 2.");
CM_LOG_E("abort arguments count is not expected");
return nullptr;
}
@ -525,7 +525,7 @@ static napi_value ParseCMAbortParams(napi_env env, napi_callback_info info, Sign
size_t index = 0;
napi_value result = GetBlob(env, argv[index], context->handle);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "handle is not a uint8Array or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "handle is not a uint8Array or the length is 0 or too long.");
CM_LOG_E("get handle failed when using abort function");
return nullptr;
}
@ -534,7 +534,7 @@ static napi_value ParseCMAbortParams(napi_env env, napi_callback_info info, Sign
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function failed when using abort function");
return nullptr;
}
@ -729,7 +729,7 @@ static napi_value CMInitAsyncWork(napi_env env, SignVerifyAsyncContext context)
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "queue async work error");
ThrowError(env, PARAM_ERROR, "queue async work error");
CM_LOG_E("queue async work failed when using init function");
return nullptr;
}
@ -753,7 +753,7 @@ static napi_value CMUpdateAsyncWork(napi_env env, SignVerifyAsyncContext context
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "queue async work error");
ThrowError(env, PARAM_ERROR, "queue async work error");
CM_LOG_E("queue async work failed when using update function");
return nullptr;
}
@ -777,7 +777,7 @@ static napi_value CMFinishAsyncWork(napi_env env, SignVerifyAsyncContext context
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "queue async work error");
ThrowError(env, PARAM_ERROR, "queue async work error");
CM_LOG_E("queue async work failed when using finish function");
return nullptr;
}
@ -801,7 +801,7 @@ static napi_value CMAbortAsyncWork(napi_env env, SignVerifyAsyncContext context)
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "queue async work error");
ThrowError(env, PARAM_ERROR, "queue async work error");
CM_LOG_E("queue async work failed when using abort function");
return nullptr;
}

View File

@ -69,7 +69,7 @@ static napi_value UninstallAllAppCertParseParams(
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_UNINSTALL_ALL_APP_CERT_MIN_ARGS) && (argc != CM_NAPI_UNINSTALL_ALL_APP_CERT_MAX_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "Missing parameter");
ThrowError(env, PARAM_ERROR, "Missing parameter");
CM_LOG_E("Missing parameter");
return nullptr;
}
@ -79,7 +79,7 @@ static napi_value UninstallAllAppCertParseParams(
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when uninstall all app cert function");
return nullptr;
}

View File

@ -65,7 +65,7 @@ napi_value UninstallAppCertParseParams(
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if ((argc != CM_NAPI_UNINSTALL_APP_CERT_MIN_ARGS) && (argc != CM_NAPI_UNINSTALL_APP_CERT_MAX_ARGS)) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 1 and 2.");
ThrowError(env, PARAM_ERROR, "arguments count invalid, arguments count need between 1 and 2.");
CM_LOG_E("arguments count invalid. argc = %d", argc);
return nullptr;
}
@ -73,7 +73,7 @@ napi_value UninstallAppCertParseParams(
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->keyUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "keyUri is not a string or the length is 0 or too long.");
ThrowError(env, PARAM_ERROR, "keyUri is not a string or the length is 0 or too long.");
CM_LOG_E("could not get cert uri");
return nullptr;
}
@ -82,7 +82,7 @@ napi_value UninstallAppCertParseParams(
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
ThrowError(env, PARAM_ERROR, "Get callback failed, callback must be a function.");
CM_LOG_E("get callback function faild when uninstall applicaiton cert");
return nullptr;
}

View File

@ -140,7 +140,7 @@ static napi_value ParseInstallUserCertParams(napi_env env, napi_callback_info in
if ((argc != CM_NAPI_USER_INSTALL_ARGS_CNT) &&
(argc != (CM_NAPI_USER_INSTALL_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid when installing user cert");
ThrowError(env, PARAM_ERROR, "arguments count invalid when installing user cert");
CM_LOG_E("arguments count is not expected when installing user cert");
return nullptr;
}
@ -148,7 +148,7 @@ static napi_value ParseInstallUserCertParams(napi_env env, napi_callback_info in
size_t index = 0;
napi_value result = ParseCertInfo(env, argv[index], context);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "get context type error");
ThrowError(env, PARAM_ERROR, "get context type error");
CM_LOG_E("get CertBlob failed when installing user cert");
return nullptr;
}
@ -157,7 +157,7 @@ static napi_value ParseInstallUserCertParams(napi_env env, napi_callback_info in
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when install user cert");
return nullptr;
}
@ -174,7 +174,7 @@ static napi_value ParseUninstallUserCertParams(napi_env env, napi_callback_info
if ((argc != CM_NAPI_USER_UNINSTALL_ARGS_CNT) &&
(argc != (CM_NAPI_USER_UNINSTALL_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid when uninstalling user cert");
ThrowError(env, PARAM_ERROR, "arguments count invalid when uninstalling user cert");
CM_LOG_E("arguments count is not expected when uninstalling user cert");
return nullptr;
}
@ -182,7 +182,7 @@ static napi_value ParseUninstallUserCertParams(napi_env env, napi_callback_info
size_t index = 0;
napi_value result = ParseString(env, argv[index], context->certUri);
if (result == nullptr) {
ThrowParamsError(env, PARAM_ERROR, "get certUri type error");
ThrowError(env, PARAM_ERROR, "get certUri type error");
CM_LOG_E("get CertBlob failed when uninstalling user cert");
return nullptr;
}
@ -191,7 +191,7 @@ static napi_value ParseUninstallUserCertParams(napi_env env, napi_callback_info
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when uninstalling user cert");
return nullptr;
}
@ -208,7 +208,7 @@ static napi_value ParseUninstallAllUserCertParams(napi_env env, napi_callback_in
if ((argc != CM_NAPI_USER_UNINSTALL_ALL_ARGS_CNT) &&
(argc != (CM_NAPI_USER_UNINSTALL_ALL_ARGS_CNT - CM_NAPI_CALLBACK_ARG_CNT))) {
ThrowParamsError(env, PARAM_ERROR, "arguments count invalid when uninstalling all user cert");
ThrowError(env, PARAM_ERROR, "arguments count invalid when uninstalling all user cert");
CM_LOG_E("arguments count is not expected when uninstalling all user cert");
return nullptr;
}
@ -217,7 +217,7 @@ static napi_value ParseUninstallAllUserCertParams(napi_env env, napi_callback_in
if (index < argc) {
int32_t ret = GetCallback(env, argv[index], context->callback);
if (ret != CM_SUCCESS) {
ThrowParamsError(env, PARAM_ERROR, "Get callback type failed.");
ThrowError(env, PARAM_ERROR, "Get callback type failed.");
CM_LOG_E("get callback function failed when uninstalling all user cert");
return nullptr;
}
@ -299,7 +299,7 @@ static napi_value InstallUserCertAsyncWork(napi_env env, UserCertAsyncContext co
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "queue async work error");
ThrowError(env, PARAM_ERROR, "queue async work error");
CM_LOG_E("queue async work failed when installing user cert");
return nullptr;
}
@ -349,7 +349,7 @@ static napi_value UninstallUserCertAsyncWork(napi_env env, UserCertAsyncContext
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "queue async work error");
ThrowError(env, PARAM_ERROR, "queue async work error");
CM_LOG_E("queue async work failed when uninstalling user cert");
return nullptr;
}
@ -379,7 +379,7 @@ static napi_value UninstallAllUserCertAsyncWork(napi_env env, UserCertAsyncConte
napi_status status = napi_queue_async_work(env, context->asyncWork);
if (status != napi_ok) {
ThrowParamsError(env, PARAM_ERROR, "queue async work error");
ThrowError(env, PARAM_ERROR, "queue async work error");
CM_LOG_E("queue async work failed uninstall all user cert");
return nullptr;
}