* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
* MindIE is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
#ifndef MINDIE_LLM_ERROR_H
#define MINDIE_LLM_ERROR_H
#include <string>
#include <utility>
namespace mindie_llm {
class Error {
public:
enum class Code {
OK,
ERROR,
INVALID_ARG,
NOT_FOUND,
};
explicit Error(Code code = Code::OK) : code_(code) {}
explicit Error(Code code, std::string msg) : code_(code), msg_(std::move(msg)) {}
Code ErrorCode() const { return code_; }
const std::string &Message() const { return msg_; }
bool IsOk() const { return code_ == Code::OK; }
std::string ToString() const;
static const char *CodeToString(const Code code);
protected:
Code code_;
std::string msg_;
};
}
#endif