# 02 · structured-error-object **演示**:`error({ code="E_TYPE" })`,`pcall` 返回同一张表。 **运行时**:`lua54`、`luajit`。 **运行**: ```sh .tools/bin/lua54 scripts/run-example.lua examples/20-error-handling/02-structured-error-object .tools/bin/lua54 scripts/test-example.lua examples/20-error-handling/02-structured-error-object ``` **预期输出**(lua 5.4.9 / macOS arm64): ```text ok=false code=E_TYPE ``` **看点**:错误对象可以带字段,便于机器处理;不要只拼字符串。 **注意**:`error` 的表不会自动加 traceback,需配合 xpcall。