Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "adapter_error_manager.h"
12 : #include "adapter_error_manager_pub.h"
13 : #include "base/err_msg.h"
14 : #include "base/err_mgr.h"
15 :
16 105 : void RptInputErr(std::string error_code, std::vector<std::string> key, std::vector<std::string> value)
17 : {
18 : // 将 std::vector<std::string> 转换为 std::vector<const char*>
19 105 : std::vector<const char*> key_cstr;
20 311 : for (const auto& k : key) {
21 205 : key_cstr.push_back(k.c_str());
22 : }
23 :
24 105 : std::vector<const char*> value_cstr;
25 310 : for (const auto& v : value) {
26 206 : value_cstr.push_back(v.c_str());
27 : }
28 :
29 : // 调用 REPORT_PREDEFINED_ERR_MSG
30 104 : REPORT_PREDEFINED_ERR_MSG(error_code.c_str(), key_cstr, value_cstr);
31 210 : return;
32 105 : }
33 :
34 1 : void RptInnerErrPrt(const char* fmt, ...)
35 : {
36 : va_list args;
37 1 : va_start(args, fmt);
38 1 : char errorMsgStr[LIMIT_PER_MESSAGE] = {};
39 1 : int ret = vsnprintf_s(errorMsgStr, LIMIT_PER_MESSAGE, LIMIT_PER_MESSAGE - 1U, fmt, args);
40 1 : va_end(args);
41 1 : if (ret == -1) {
42 0 : return;
43 : }
44 1 : REPORT_INNER_ERR_MSG(HCCL_RPT_CODE, "%s", errorMsgStr);
45 : }
|