pub enum CommandError {
UnknownCommand,
KindMismatch {
expected: &'static str,
actual: &'static str,
},
MissingTarget,
MotionFailed,
User(String),
InvalidArgs(&'static str),
BadArgs(String),
Plugin(String),
Cancelled,
Core(CoreError),
Protocol(ProtocolError),
}Expand description
Why a grammar invocation failed. See the module docs for the no-effect-on-error contract every variant shares.
Variants§
UnknownCommand
The invocation named a crate::CommandId (or a motion / operator /
text-object id) that is not in the crate::CommandRegistry – e.g.
a plugin contribution that has since been unloaded, or a stale id
carried in a recorded macro.
KindMismatch
The id resolved, but to a registration of a different kind than the call site needs (an operator id passed where a motion was expected). A programming error in the caller, not a user error.
Fields
MissingTarget
An operator invocation carried neither a crate::Target nor a
crate::Range, so there is nothing to operate on. The keystroke
parser never builds such an invocation; this guards programmatic
callers (plugins, replayed macros).
MotionFailed
VM.3L: a motion couldn’t move (vim beeps): j on the last line, k
on the first. The dispatcher commits no effect, so an operator it was
feeding is cancelled — vim deletes nothing for dj on the last line,
where returning the cursor would have deleted that line.
User(String)
VM.3d-2: a command failed with a message the user should see — vim’s
E486: Pattern not found, E35: no previous regular expression. Like
every error, no effect is committed (an operator fed by a failing n
deletes nothing, as in vim); unlike the others, the host echoes it.
InvalidArgs(&'static str)
The evaluator received crate::Args of the wrong shape, or args
that do not fit the document (the common case is a position computed
past the end of the buffer). The static string names what was wrong;
it is for logs, not the user.
BadArgs(String)
An ex-command’s parse_args callback rejected the input. Carries
the human-readable reason; the parser front-end surfaces it through
ExCommandError::BadArgs.
Plugin(String)
A WASM-plugin grammar contribution failed at apply / parse_args
(PH7.7c): a guest-returned err, a fuel/epoch trap (the Reflex-budget
runaway guard), a boundary-conversion failure, or a dead plugin. The
dispatcher treats it like any evaluator error — no Effect is
committed, the contribution is a no-op (graceful degradation,
plugin-host.md §8), and the reason is logged. Built-in grammar never
produces this.
Cancelled
The evaluator observed a cancelled crate::CancellationToken
and returned early. By DESIGN.md §5.2.5, no Effect is
committed; the document is left at the version the keystroke
arrived at, exactly as if the user had not pressed the key.
Core(CoreError)
A buffer-model failure from [lattice_core] (I/O, nothing to
undo/redo, a core-level cancellation) surfaced through ?.
Protocol(ProtocolError)
A protocol-layer failure from [lattice_protocol] (unknown
document, out-of-bounds position, stale version) surfaced through
?.
Trait Implementations§
Source§impl Debug for CommandError
impl Debug for CommandError
Source§impl Display for CommandError
impl Display for CommandError
Source§impl Error for CommandError
impl Error for CommandError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()