Skip to main content

continuity_engine/
error.rs

1//! Errors returned by the synchronous editor engine.
2
3use continuity_buffer::Revision;
4use thiserror::Error;
5
6/// Errors from storage-neutral editor operations.
7#[derive(Debug, Error)]
8pub enum Error {
9    /// A mutation targeted a buffer that is not owned by this engine.
10    #[error("unknown buffer id")]
11    UnknownBuffer,
12
13    /// A revision-checked mutation targeted stale content.
14    #[error("revision mismatch: expected {expected:?}, actual {actual:?}")]
15    RevisionMismatch {
16        /// Revision supplied by the caller.
17        expected: Revision,
18        /// Current engine revision.
19        actual: Revision,
20    },
21
22    /// A host-provided change-batch sequence was internally inconsistent.
23    #[error("invalid change batch: {0}")]
24    InvalidChangeBatch(String),
25
26    /// An error from the buffer layer.
27    #[error(transparent)]
28    Buffer(#[from] continuity_buffer::Error),
29
30    /// An error from the text-coordinate layer.
31    #[error(transparent)]
32    Text(#[from] continuity_text::Error),
33
34    /// A command argument was outside its supported domain.
35    #[error("invalid argument for `{name}`: {reason}")]
36    InvalidArgument {
37        /// Command that received the invalid argument.
38        name: &'static str,
39        /// Human-readable failure reason.
40        reason: String,
41    },
42}