1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DRM_ERROR_CODE_H 17 #define DRM_ERROR_CODE_H 18 #include "napi/native_api.h" 19 #include "napi/native_common.h" 20 #include "napi/native_node_api.h" 21 22 namespace OHOS { 23 namespace DrmStandard { 24 class NapiDrmError { 25 public: 26 static napi_status ThrowError(napi_env env, const char *napiMessage, int32_t napiCode); 27 static void ThrowError(napi_env env, int32_t code); 28 static std::string GetMessageByCode(int32_t &code); 29 }; 30 31 const int32_t DRM_ERROR = -1; 32 const int32_t DRM_OK = 0; 33 const int32_t DRM_ALLOC_ERROR = 1; 34 const int32_t DRM_INVALID_ARG = 2; 35 const int32_t DRM_INVALID_STATE = 3; 36 const int32_t DRM_OPERATION_NOT_ALLOWED = 5; 37 const int32_t DRM_HOST_ERROR = 6; 38 const int32_t DRM_SERVICE_ERROR = 7; 39 const int32_t DRM_MEMORY_ERROR = 8; 40 const int32_t DRM_UNKNOWN_ERROR = 24700101; 41 const int32_t DRM_MAX_SYSTEM_NUM_REACHED = 24700103; 42 const int32_t DRM_MAX_SESSION_NUM_REACHED = 24700104; 43 const int32_t DRM_SERVICE_FATAL_ERROR = 24700201; 44 const int32_t DRM_INVALID_PARAM = 401; 45 46 const std::string DRM_INVALID_PARAM_INFO = "input parameter value error"; 47 const std::string DRM_SERVICE_FATAL_ERRO_INFO = "service error"; 48 const std::string DRM_UNKNOWN_ERROR_INFO = "unknow error"; 49 const std::string DRM_MAX_SYSTEM_NUM_REACHED_INFO = "mediaKeySystem number limited"; 50 const std::string DRM_MAX_SESSION_NUM_REACHED_INFO = "mediaKeySession number limited"; 51 } // namespace DrmStandard 52 } // namespace OHOS 53 #endif // DRM_ERROR_CODE_H