Skip to main content

CommandError

Enum CommandError 

Source
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

§expected: &'static str

The kind the call site required, as its registry label ("motion", "operator", "text-object", "ex-command", "action").

§actual: &'static str

The kind the id actually names, same label vocabulary.

§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CommandError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CommandError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<CoreError> for CommandError

Source§

fn from(source: CoreError) -> Self

Converts to this type from the input type.
Source§

impl From<ProtocolError> for CommandError

Source§

fn from(source: ProtocolError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more