---
title: ToString接口
description: "将返回对象转为字符串格式，具体为错误码映射为相应字符后，和错误信息以\"： \"进行拼接。"
url: https://www.hiascend.com/document/detail/zh/mindie/latest/mindiellm/llmdev/mindie_llm0124.html
sourcePath: /source/zh/mindie/310/mindiellm/llmdev/mindie_llm0124.html
indexId: e5a4dfdb29caa6923ea9e645f68ff8d8e4c44fa5609ec8eeb7bfb999da6eb19558
---
# ToString接口

#### 接口功能

将返回对象转为字符串格式，具体为错误码映射为相应字符后，和错误信息以"： "进行拼接。


#### 接口格式

```
std::string ToString() const;
```


#### 接口参数

无。


#### 使用样例

构造一个Error对象，将返回对象转为字符串格式，具体为错误码映射为相应字符后，和错误信息以"： "进行拼接。

```
auto err = Error(Error::Code::ERROR, "ERROR: Failed to get real path of home.");
err.ToString();
```


#### 返回值

对象转化出来的字符串。

| Error对象 | 返回字符格式 |
| --- | --- |
| Error::Code::OK | OK: + msg |
| Error::Code::ERROR | Error: +msg |
| Error::Code::INVALID\_ARG | Invalid argument: +msg |
| Error::Code::NOT\_FOUND | Not found: +msg |
