mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-22 04:55:33 -04:00
修复screenshot errorCode打印问题
Signed-off-by: youqijing <youqijing@huawei.com> Change-Id: Ie9c32657e0329bf4c60529855d2cda7172cb0085
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "wm_napi_common.h"
|
||||
|
||||
#include <securec.h>
|
||||
#include <string>
|
||||
|
||||
#include <hilog/log.h>
|
||||
@@ -23,6 +24,8 @@
|
||||
#include "bundle_constants.h"
|
||||
#include "ipc_skeleton.h"
|
||||
|
||||
const int ERROR_CODE_LEN = 16; // 16 is the max len of error code
|
||||
|
||||
namespace OHOS {
|
||||
napi_status SetMemberInt32(napi_env env, napi_value result, const char *key, int32_t value)
|
||||
{
|
||||
@@ -69,9 +72,10 @@ void SetErrorInfo(napi_env env, Rosen::WMError wret, std::string errMessage, nap
|
||||
}
|
||||
napi_value code = nullptr;
|
||||
napi_value message = nullptr;
|
||||
auto errorCode = static_cast<int32_t>(wret);
|
||||
char errorCode[ERROR_CODE_LEN];
|
||||
(void)sprintf_s(errorCode, sizeof(errorCode), "%d", static_cast<int32_t>(wret));
|
||||
napi_create_string_utf8(env, errorCode, strlen(errorCode), &code);
|
||||
napi_create_string_utf8(env, errMessage.c_str(), strlen(errMessage.c_str()), &message);
|
||||
napi_create_uint32(env, errorCode, &code);
|
||||
napi_create_error(env, code, message, &result[0]);
|
||||
napi_get_undefined(env, &result[1]);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, OHOS::Rosen::HILOG_DOMAIN_WINDOW,
|
||||
"NapiWindowManagerCommonLayer" };
|
||||
|
||||
const int PARAMNUMBER = 2; // 2: callback func input number, also reused by Promise
|
||||
const int PARAM_NUMBER = 2; // 2: callback func input number, also reused by Promise
|
||||
|
||||
#define GNAPI_LOG(fmt, ...) OHOS::HiviewDFX::HiLog::Info(LABEL, \
|
||||
"%{public}s:%{public}d " fmt, __func__, __LINE__, ##__VA_ARGS__)
|
||||
@@ -111,17 +111,17 @@ napi_value AsyncProcess(napi_env env,
|
||||
|
||||
auto completeFunc = [](napi_env env, napi_status status, void *data) {
|
||||
AsyncCallbackInfo *info = reinterpret_cast<AsyncCallbackInfo *>(data);
|
||||
napi_value result[PARAMNUMBER] = {0};
|
||||
napi_value result[PARAM_NUMBER] = {0};
|
||||
if (info->param->wret == Rosen::WMError::WM_OK) {
|
||||
napi_get_undefined(env, &result[0]);
|
||||
result[1] = info->resolve(env, info->param);
|
||||
} else {
|
||||
SetErrorInfo(env, info->param->wret, info->param->errMessage, result, PARAMNUMBER);
|
||||
SetErrorInfo(env, info->param->wret, info->param->errMessage, result, PARAM_NUMBER);
|
||||
}
|
||||
if (info->deferred) {
|
||||
ProcessPromise(env, info->param->wret, info->deferred, result, PARAMNUMBER);
|
||||
ProcessPromise(env, info->param->wret, info->deferred, result, PARAM_NUMBER);
|
||||
} else {
|
||||
ProcessCallback(env, info->ref, result, PARAMNUMBER);
|
||||
ProcessCallback(env, info->ref, result, PARAM_NUMBER);
|
||||
}
|
||||
napi_delete_async_work(env, info->asyncWork);
|
||||
delete info;
|
||||
|
||||
Reference in New Issue
Block a user