use canvist_model::BlockId;
use canvist_model::StepError;
#[derive(Debug, thiserror::Error)]
pub enum CollabError {
#[error(
"shared block nesting exceeds the limit of {} levels",
crate::MAX_BLOCK_DEPTH
)]
BlockDepthLimit,
#[error(transparent)]
Step(#[from] StepError),
#[error("block {0} is not in the shared document")]
NotShared(BlockId),
#[error("offset {offset} does not fit the text of block {block}")]
Offset {
block: BlockId,
offset: u32,
},
#[error("the document and the shared document have diverged")]
Diverged,
#[error("expected a nested shared type")]
RootType,
#[error("the shared document is busy with another transaction")]
Busy,
#[error("the shared document already has content")]
NotEmpty,
#[error("malformed payload: {0}")]
Decode(#[from] yrs::encoding::read::Error),
#[error("invalid update: {0}")]
Update(#[from] yrs::error::UpdateError),
#[error("awareness: {0}")]
Awareness(#[from] yrs::sync::awareness::Error),
#[error("permission denied: {0}")]
PermissionDenied(String),
#[error("the server closed the document: {0}")]
Closed(String),
#[error("unsupported message type {0}")]
UnsupportedMessage(u8),
#[cfg(feature = "scene")]
#[error("node {0} is not in the shared scene")]
SceneNode(canvist_scene::NodeId),
#[cfg(feature = "scene")]
#[error(transparent)]
Scene(#[from] canvist_scene::SceneError),
}