Skip to content

repl: add LeanError/TacticError exception hierarchy - #2

Merged
AndPuQing merged 1 commit into
mainfrom
agent/leo3/9ed5efd73ddb
Aug 25, 2026
Merged

AndPuQing merged 1 commit into
mainfrom
agent/leo3/9ed5efd73ddb

Conversation

@AndPuQing

Copy link
Copy Markdown
Contributor

W-403:在 Python 包装层引入可区分、可捕获的异常层级(向后兼容)。

  • LeanError(RuntimeError) / TacticError(LeanError),加入 __all__
  • Repl 包装层按类型重抛(raise NewType(str(e)) from e,保留消息与 cause):run_tac/run_tacs → TacticError;set_goal/check/inspect/run_cmd → LeanError
  • 现有 except RuntimeError 捕获逻辑不受影响(有测试覆盖)
  • 仅 Python 改动,Rust 未变;uv run pytest 63 passed / 1 skipped

评审:Leo3 Reviewer 已通过(W-403 评论线程)。

All failures raised bare RuntimeError, forcing callers (RL / proof
search loops) to string-match messages to tell an expected tactic
failure from a parse error, unknown state, or internal error.

- LeanError(RuntimeError): base for leotower Lean-operation errors,
  raised by set_goal / check / inspect / run_cmd failures.
- TacticError(LeanError): tactic parse/elaboration/application failure;
  session and replay state stay usable. Raised by run_tac / run_tacs
  (try_run_tac / try_run_tacs are non-raising and untouched).
- Repl wrappers re-raise via 'raise NewType(str(e)) from e', preserving
  the original message and cause.
- Backward compatible: both refine RuntimeError, so existing
  'except RuntimeError' handlers keep working (covered by tests).

Rust unchanged; existing error tests (match="...") pass as-is.
@AndPuQing
AndPuQing merged commit c0a8ae3 into main Aug 25, 2026
2 of 5 checks passed
@AndPuQing
AndPuQing deleted the agent/leo3/9ed5efd73ddb branch August 25, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant