AI 新闻雷达
返回
github.com

Add top-level CLI error handling with defined exit codes and stderr discipline

目标用户 · developer

阅读原文

Add top-level CLI error handling with defined exit codes and stderr discipline: ## Summary Catch expected failure classes (`ValueError` from validation, `FileNotFoundError` for inputs, permission errors for outputs) in `cli.py::main`, print concise messages to stderr, and exit with documented codes

个性化解读(发生了什么 / 为什么重要 / 影响 / 建议)将在接入 LLM 后按你的角色生成。

痛点信号

  • ## why this matters the first thing a new user with slightly-wrong data sees today is a python traceback ending in `valueerror` or `keyerror` — correct information, hostile presentation, and exit status that ci can't distinguish from a crash.
  • ## current evidence - `cli.py::main` is `args.func(args)` with no error handling; `load_logged_decisions` and `offlineevaluator._validate_row` raise `valueerror`; a missing `--input` file raises `filenotfounderror` from `path.open`.
  • wrap dispatch in `main()` with a small `try/except (valueerror, oserror)` mapping to message + `sys.exit(2)`; keep unexpected exceptions as tracebacks (genuine bugs should stay loud).
  • ## acceptance criteria - missing input file → one-line stderr message, exit 2, no traceback.
  • ## risks and tradeoffs over-catching can hide bugs — keep the caught set narrow and deliberate.
#developer#agent#issues