Status接口
接口功能
- 通过错误码创建状态对象。
- 通过错误码和string类型的msg创建状态对象。
- 通过Error对象创建状态。
接口格式
explicit Status(Error::Code code = Error::Code::OK) noexcept; explicit Status(Error::Code code, const std::string &msg); explicit Status(const Error &error);
接口参数
参数 |
是否必选 |
说明 |
取值要求 |
---|---|---|---|
code |
必选 |
错误码。 |
|
参数 |
是否必选 |
说明 |
取值要求 |
---|---|---|---|
code |
必选 |
错误码。 |
|
msg |
必选 |
错误信息. |
合法字符串。 |
参数 |
是否必选 |
说明 |
取值要求 |
---|---|---|---|
error |
必选 |
错误信息返回对象。 |
合法错误信息返回对象。 |
使用样例
Status(Error::Code::OK); Status(Error::Code::ERROR, "Engine init model failed: new modelBackend failed"); Status CommonErrorToStatus(const Error &error) { return Status(error); }
返回值
返回状态对象。
父主题: Status