参考
退出码
CLI 把失败映射到进程退出码的方式。
| 退出码 | 含义 |
|---|---|
0 | 成功 —— stdout 输出 { ok: true, result } |
1 | 运行时 / 网络失败 —— 如 task_failed、timeout、network_error、unauthorized、insufficient_balance、cli_version_too_low |
2 | 输入 / 配置错误 —— 如 tool_not_found、missing_field、bad_ref、no_stdin、input_file_not_found、input_file_bad_json |
退出码与 { ok: false, code, message, details? } 信封配合:机器看 code、人看 message、shell 用 $? 提前短路。
if ! dlazy gpt-image-2 --prompt "..." > out.json; then
case $? in
1) echo "运行时/网络失败" >&2 ;;
2) echo "参数有问题" >&2 ;;
esac
exit 1
fi