@weintek/libc/string
@weintek/libc/string 模块提供将错误码转换为可读消息的方法。
参考 C 标准库 设计。
注意: 仅在本地 HMI 上运行自定义模型脚本时可用。
导入
js
const cstring = await import('@weintek/libc/string');函数
strerror(errnum)
返回错误码对应的文字描述。
详见 cppreference.com。
| 名称 | 类型 | 描述 |
|---|---|---|
errnum | Number | 由 getErrno() 获取的错误码。 |
返回值: String — 错误的可读描述。
范例
js
const cerrno = await import('@weintek/libc/errno');
const cstring = await import('@weintek/libc/string');
const errCode = cerrno.getErrno();
const errMessage = cstring.strerror(errCode);
console.log(`错误: ${errMessage}`);