Skip to content

Commit 474db93

Browse files
committed
more robust error handling
1 parent 3d336e8 commit 474db93

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

REPL/Main.lean

+5-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def unpickleProofSnapshot (n : UnpickleProofState) : M IO ProofStepResponse := d
161161
/--
162162
Run a command, returning the id of the new environment, and any messages and sorries.
163163
-/
164-
def runCommand (s : Command) : M m (CommandResponse ⊕ Error) := do
164+
def runCommand (s : Command) : M IO (CommandResponse ⊕ Error) := do
165165
let (cmdSnapshot?, notFound) ← do match s.env with
166166
| none => pure (none, false)
167167
| some i => do match (← get).cmdStates[i]? with
@@ -170,7 +170,10 @@ def runCommand (s : Command) : M m (CommandResponse ⊕ Error) := do
170170
if notFound then
171171
return .inr ⟨"Unknown environment."
172172
let cmdState? := cmdSnapshot?.map fun c => c.cmdState
173-
let (cmdState, messages, trees) ← IO.processInput s.cmd cmdState?
173+
let (cmdState, messages, trees) ← try
174+
IO.processInput s.cmd cmdState?
175+
catch ex =>
176+
return .inr ⟨ex.toString⟩
174177
let messages ← messages.mapM fun m => Message.of m
175178
let sorries ← sorries trees
176179
let tactics ← match s.allTactics with

test/Mathlib/ReplMathlibTests/20231025.lean

-10
This file was deleted.

0 commit comments

Comments
 (0)