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 : #include "adapter_error_manager.h"
11 : #include "adapter_error_manager_pub.h"
12 : #include "base/err_msg.h"
13 : #include "base/err_mgr.h"
14 :
15 105 : void RptInputErr(std::string error_code, std::vector<std::string> key, std::vector<std::string> value)
16 : {
17 : // 将 std::vector<std::string> 转换为 std::vector<const char*>
18 105 : std::vector<const char*> key_cstr;
19 310 : for (const auto& k : key) {
20 205 : key_cstr.push_back(k.c_str());
21 : }
22 :
23 105 : std::vector<const char*> value_cstr;
24 311 : for (const auto& v : value) {
25 206 : value_cstr.push_back(v.c_str());
26 : }
27 :
28 : // 调用 REPORT_PREDEFINED_ERR_MSG
29 105 : REPORT_PREDEFINED_ERR_MSG(error_code.c_str(), key_cstr, value_cstr);
30 209 : return;
31 105 : }
32 :
33 1 : void RptInnerErrPrt(const char* fmt, ...)
34 : {
35 : va_list args;
36 1 : va_start(args, fmt);
37 1 : char errorMsgStr[LIMIT_PER_MESSAGE] = {};
38 1 : int ret = vsnprintf_s(errorMsgStr, LIMIT_PER_MESSAGE, LIMIT_PER_MESSAGE - 1U, fmt, args);
39 1 : va_end(args);
40 1 : if (ret == -1) {
41 0 : return;
42 : }
43 1 : REPORT_INNER_ERR_MSG(HCCL_RPT_CODE, "%s", errorMsgStr);
44 : }
|