Files
LuaCangjia_api/lib/errors.h
JianFeeeee 4af121c1f3 refactor!: 错误码体系重构 删除特殊平台语境残留
BREAKING CHANGE: 错误码编号全部变更, 外部依赖旧编号的代码需按映射表更新

- 删除 10 个从未使用的错误码:
  JSON/MCP 系列(5001/5002/5006/5007/5008) + 其余死码(5004/5009/5013/5018/5021)
- 重排为连续 5001~5016
- 宏前缀 NAPI_(鸿蒙 NAPI 语境残留) 改为 LUAERR_
- 同步更新: errors.h / bridge.cj getErrorMessage+typed抛出点 /
  lua_runner_test.cj 断言 / api.md 对照表 / README.md / GTest 宏名
- 清理注释残留: 鸿蒙 el2 沙盒路径 TODO / 沙盒内路径描述
- 版本号 0.2.1 -> 0.2.2

验证: GTest 44/44 通过; cjpm build 成功; 独立程序运行时 9/9 通过
(含新编号 5016/5013 错误路径)
2026-08-25 09:29:48 +08:00

23 lines
1.6 KiB
C
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef ERRORS
#define ERRORS
// LuaCangjia_api 统一错误码体系5001~5016 连续编号C++ 层与仓颉层共用。
// 仓颉侧 LuaError.code 与此处数字一一对应,修改时需同步 src/bridge.cj 的
// getErrorMessage 与 doc/api.md 的错误码对照表。
#define LUAERR_LOAD_FILE 5001 //文件加载错误,可能为权限、路径或编译期语法问题
#define LUAERR_LUA_STATE 5002 //lua状态机初始化错误或损坏
#define LUAERR_SCRIPT_ERROR 5003 //脚本内部错误取result获取更多信息
#define LUAERR_SCRIPT_BAD_RET 5004 //脚本返回值类型不符合要求
#define LUAERR_UNLOADLIB_FAIL 5005 //释放的库未被加载
#define LUAERR_LUA_STACK 5006 //函数调用时,栈布局与约定不符
#define LUAERR_INIT_FAIL 5007 //lua状态机初始化失败
#define LUAERR_LIB_OVERFLOW 5008 //加载的库数量超过上限
#define LUAERR_CLASS_LOST 5009 //luarunner对象丢失
#define LUAERR_RESET_INPUT_FILE 5010 //重置输入文件失败,可能造成输入污染
#define LUAERR_CALLBACK 5011 //回调函数执行错误含doString语法错误
#define LUAERR_NOCHUNK_FOUND 5012 //没有找到待调用的函数
#define LUAERR_FUNCTION_NOT_FOUND 5013 //callfunction时未找到指定函数
#define LUAERR_FUNC_OVERFLOW 5014 //预加载函数数量超过上限
#define LUAERR_FUNCTION_INVALID 5015 //预加载文件顶层执行后返回的不是函数
#define LUAERR_RESULT_TYPE 5016 //结果类型不支持如将string读作int
#endif