• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 #ifndef NAPI_AUDIO_ERROR_H
16 #define NAPI_AUDIO_ERROR_H
17 
18 #include <map>
19 #include <string>
20 #include "napi/native_api.h"
21 #include "napi/native_common.h"
22 #include "napi/native_node_api.h"
23 #include "audio_errors.h"
24 
25 namespace OHOS {
26 namespace AudioStandard {
27 
28 constexpr int32_t NAPI_ERROR_INVALID_PARAM = 6800101;
29 constexpr int32_t NAPI_ERR_NO_PERMISSION = 201;
30 constexpr int32_t NAPI_ERR_PERMISSION_DENIED = 202;
31 constexpr int32_t NAPI_ERR_INPUT_INVALID = 401;
32 constexpr int32_t NAPI_ERR_INVALID_PARAM = 6800101;
33 constexpr int32_t NAPI_ERR_NO_MEMORY = 6800102;
34 constexpr int32_t NAPI_ERR_ILLEGAL_STATE = 6800103;
35 constexpr int32_t NAPI_ERR_UNSUPPORTED = 6800104;
36 constexpr int32_t NAPI_ERR_TIMEOUT = 6800105;
37 constexpr int32_t NAPI_ERR_STREAM_LIMIT = 6800201;
38 constexpr int32_t NAPI_ERR_SYSTEM = 6800301;
39 
40 class NapiAudioError {
41 public:
42     static napi_status ThrowError(napi_env env, const char *napiMessage, int32_t napiCode);
43     static void ThrowError(napi_env env, int32_t code);
44     static void ThrowError(napi_env env, int32_t code, const std::string &errMessage);
45     static napi_value ThrowErrorAndReturn(napi_env env, int32_t errCode);
46     static napi_value ThrowErrorAndReturn(napi_env env, int32_t errCode, const std::string &errMessage);
47     static std::string GetMessageByCode(int32_t &code);
48 };
49 } // namespace AudioStandard
50 } // namespace OHOS
51 #endif // NAPI_AUDIO_ERROR_H
52