diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 6651e13f..4ff3d02b 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -199,37 +199,6 @@ const int32_t MAX_EVENT_NUMBER = 10; const int32_t EXPAND_TWICE = 2; const int32_t SEC_TO_MM = 1000; const int32_t MAX_EVENTS = 5; - -// error code info -const std::string DM_FAILED_INFO = "dm process execution failed."; -const std::string DM_TIME_OUT_INFO = "dm process execution timeout."; -const std::string DM_NOT_INIT_INFO = "dm service is not initialized, please try again later."; -const std::string DM_INIT_REPEATED_INFO = "dm service repeated initialization."; -const std::string DM_INIT_FAILED_INFO = "dm service initialize failed."; -const std::string DM_UNINIT_FAILED_INFO = "dm Service uninitialization failed."; -const std::string DM_POINT_NULL_INFO = "dm service null pointer exception occurred."; -const std::string DM_INPUT_PARAMETER_EMPTY_INFO = "the function call input parameter is empty."; -const std::string DM_NO_PERMISSION_INFO = "no permission for function call."; -const std::string DM_MALLOC_FAILED_INFO = "memory allocation failed."; -const std::string DM_DISCOVERY_FAILED_INFO = "device discovery failed."; -const std::string DM_MAP_KEY_ALREADY_EXISTS_INFO = "map key already exists."; -const std::string DM_PROFILE_EVENTS_FAILED_INFO = "process profile events failed."; -const std::string DM_IPC_WRITE_FAILED_INFO = "ipc write object failed."; -const std::string DM_IPC_COPY_FAILED_INFO = "ipc copy data failed."; -const std::string DM_IPC_SEND_REQUEST_FAILED_INFO = "ipc send request failed."; -const std::string DM_UNSUPPORTED_IPC_COMMAND_INFO = "ipc command not supported."; -const std::string DM_IPC_RESPOND_FAILED_INFO = "ipc process failed to receive response."; -const std::string DM_IPC_WRITE_TOKEN_INFO = "ipc write token failed."; -const std::string DM_DISCOVERY_REPEATED_INFO = "repeat device discovery warning."; -const std::string DM_UNSUPPORTED_AUTH_TYPE_INFO = "auth type not supported."; -const std::string DM_AUTH_BUSINESS_BUSY_INFO = "authentication service is busy."; -const std::string DM_AUTH_OPEN_SESSION_FAILED_INFO = "open auth session failed."; -const std::string DM_AUTH_PEER_REJECT_INFO = "remote device refused to authorization."; -const std::string DM_AUTH_REJECT_INFO = "local device refused to authorization."; -const std::string DM_AUTH_FAILED_INFO = "authentication failed."; -const std::string DM_AUTH_NOT_START_INFO = "auth process not started."; -const std::string DM_AUTH_MESSAGE_INCOMPLETE_INFO = "authentication message is incomplete."; -const std::string DM_CREATE_GROUP_FAILED_INFO = "create group failed."; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_CONSTANTS_H diff --git a/utils/BUILD.gn b/utils/BUILD.gn index a938e8ff..fe0ae501 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -90,7 +90,6 @@ if (defined(ohos_lite)) { "//foundation/communication/dsoftbus/interfaces/kits/transport", "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//utils/include/dm_error_message", ] sources = [ "src/dm_anonymous.cpp", diff --git a/utils/src/dm_error_message.cpp b/utils/src/dm_error_message.cpp index a5a516af..17c2d474 100644 --- a/utils/src/dm_error_message.cpp +++ b/utils/src/dm_error_message.cpp @@ -23,46 +23,47 @@ typedef struct ERROR_INFO { } ERROR_INFO; static ERROR_INFO g_errorMessages[] = { - {ERR_DM_FAILED, DM_FAILED_INFO}, - {ERR_DM_TIME_OUT, DM_TIME_OUT_INFO}, - {ERR_DM_NOT_INIT, DM_NOT_INIT_INFO}, - {ERR_DM_INIT_REPEATED, DM_INIT_REPEATED_INFO}, - {ERR_DM_INIT_FAILED, DM_INIT_FAILED_INFO}, - {ERR_DM_UNINIT_FAILED, DM_UNINIT_FAILED_INFO}, - {ERR_DM_POINT_NULL, DM_POINT_NULL_INFO}, - {ERR_DM_INPUT_PARAMETER_EMPTY, DM_INPUT_PARAMETER_EMPTY_INFO}, - {ERR_DM_NO_PERMISSION, DM_NO_PERMISSION_INFO}, - {ERR_DM_MALLOC_FAILED, DM_MALLOC_FAILED_INFO}, - {ERR_DM_DISCOVERY_FAILED, DM_DISCOVERY_FAILED_INFO}, - {ERR_DM_MAP_KEY_ALREADY_EXISTS, DM_MAP_KEY_ALREADY_EXISTS_INFO}, - {DM_PROFILE_EVENTS_FAILED, DM_PROFILE_EVENTS_FAILED_INFO}, - {ERR_DM_IPC_WRITE_FAILED, DM_IPC_WRITE_FAILED_INFO}, - {ERR_DM_IPC_COPY_FAILED, DM_IPC_COPY_FAILED_INFO}, - {ERR_DM_IPC_SEND_REQUEST_FAILED, DM_IPC_SEND_REQUEST_FAILED_INFO}, - {ERR_DM_UNSUPPORTED_IPC_COMMAND, DM_UNSUPPORTED_IPC_COMMAND_INFO}, - {ERR_DM_IPC_RESPOND_FAILED, DM_IPC_RESPOND_FAILED_INFO}, - {ERR_DM_IPC_WRITE_TOKEN_FAILED, DM_IPC_WRITE_TOKEN_INFO}, - {ERR_DM_DISCOVERY_REPEATED, DM_DISCOVERY_REPEATED_INFO}, - {ERR_DM_UNSUPPORTED_AUTH_TYPE, DM_UNSUPPORTED_AUTH_TYPE_INFO}, - {ERR_DM_AUTH_BUSINESS_BUSY, DM_AUTH_BUSINESS_BUSY_INFO}, - {ERR_DM_AUTH_OPEN_SESSION_FAILED, DM_AUTH_OPEN_SESSION_FAILED_INFO}, - {ERR_DM_AUTH_PEER_REJECT, DM_AUTH_PEER_REJECT_INFO}, - {ERR_DM_AUTH_REJECT, DM_AUTH_REJECT_INFO}, - {ERR_DM_AUTH_FAILED, DM_AUTH_FAILED_INFO}, - {ERR_DM_AUTH_NOT_START, DM_AUTH_NOT_START_INFO}, - {ERR_DM_AUTH_MESSAGE_INCOMPLETE, DM_AUTH_MESSAGE_INCOMPLETE_INFO}, - {ERR_DM_CREATE_GROUP_FAILED, DM_CREATE_GROUP_FAILED_INFO}, + {ERR_DM_FAILED, "dm process execution failed."}, + {ERR_DM_TIME_OUT, "dm process execution timeout."}, + {ERR_DM_NOT_INIT, "dm service is not initialized, please try again later."}, + {ERR_DM_INIT_REPEATED, "dm service repeated initialization."}, + {ERR_DM_INIT_FAILED, "dm service initialize failed."}, + {ERR_DM_UNINIT_FAILED, "dm Service uninitialization failed."}, + {ERR_DM_POINT_NULL, "dm service null pointer exception occurred."}, + {ERR_DM_INPUT_PARAMETER_EMPTY, "the function call input parameter is empty."}, + {ERR_DM_NO_PERMISSION, "no permission for function call."}, + {ERR_DM_MALLOC_FAILED, "memory allocation failed."}, + {ERR_DM_DISCOVERY_FAILED, "device discovery failed."}, + {ERR_DM_MAP_KEY_ALREADY_EXISTS, "map key already exists."}, + {DM_PROFILE_EVENTS_FAILED, "process profile events failed."}, + {ERR_DM_IPC_WRITE_FAILED, "ipc write object failed."}, + {ERR_DM_IPC_COPY_FAILED, "ipc copy data failed."}, + {ERR_DM_IPC_SEND_REQUEST_FAILED, "ipc send request failed."}, + {ERR_DM_UNSUPPORTED_IPC_COMMAND, "ipc command not supported."}, + {ERR_DM_IPC_RESPOND_FAILED, "ipc process failed to receive response."}, + {ERR_DM_IPC_WRITE_TOKEN_FAILED, "ipc write token failed."}, + {ERR_DM_DISCOVERY_REPEATED, "repeat device discovery warning."}, + {ERR_DM_UNSUPPORTED_AUTH_TYPE, "auth type not supported."}, + {ERR_DM_AUTH_BUSINESS_BUSY, "authentication service is busy."}, + {ERR_DM_AUTH_OPEN_SESSION_FAILED, "open auth session failed."}, + {ERR_DM_AUTH_PEER_REJECT, "remote device refused to authorization."}, + {ERR_DM_AUTH_REJECT, "local device refused to authorization."}, + {ERR_DM_AUTH_FAILED, "authentication failed."}, + {ERR_DM_AUTH_NOT_START, "auth process not started."}, + {ERR_DM_AUTH_MESSAGE_INCOMPLETE, "authentication message is incomplete."}, + {ERR_DM_CREATE_GROUP_FAILED, "create group failed."}, }; std::string GetErrorString(int failedReason) { - std::string g_errorMessage = "dm process execution failed."; + std::string errorMessage = "dm process execution failed."; for (int32_t i = 0; i < sizeof(g_errorMessages); i++) { if (failedReason == g_errorMessages[i].errCode) { - g_errorMessage = g_errorMessages[i].errMsg; + errorMessage = g_errorMessages[i].errMsg; + break; } } - return g_errorMessage; + return errorMessage; } } // namespace DistributedHardware } // namespace OHOS