use crate::model::block::BlockId;
use thiserror::Error;

#[derive(Debug, Clone, Error)]
pub enum EditorError {
    #[error("Block not found: {0}")]
    BlockNotFound(BlockId),

    #[error("Offset {offset} out of range for block {block_id} (len: {len})")]
    OffsetOutOfRange {
        block_id: BlockId,
        offset: usize,
        len: usize,
    },

    #[error("No selection")]
    NoSelection,

    #[error("Invalid operation: {0}")]
    InvalidOperation(String),

    #[error("Serialization error: {0}")]
    SerializationError(String),

    #[error("No previous block to merge with")]
    NoPreviousBlock,

    #[error("Invalid heading level: {0}")]
    InvalidHeadingLevel(u8),

    #[error("Unknown block type: {0}")]
    UnknownBlockType(String),

    #[error("Unknown mark type: {0}")]
    UnknownMarkType(String),
}
