use thiserror::Error;
use crate::hash::HashError;
use crate::operation::OperationId;
#[allow(missing_copy_implementations)]
#[derive(Error, Debug, Clone)]
pub enum DocumentBuilderError {
#[error("Every document must contain one create operation")]
NoCreateOperation,
#[error("Multiple create operations found")]
MoreThanOneCreateOperation,
#[error("All operations in a document must follow the same schema")]
OperationSchemaNotMatching,
#[error("Schema must be set")]
SchemaMustBeSet,
#[error("Operation {0} cannot be connected to the document graph")]
InvalidOperationLink(OperationId),
#[error(transparent)]
GraphSortingError(#[from] crate::graph::GraphError),
#[error(transparent)]
DocumentViewError(#[from] DocumentViewError),
}
#[allow(missing_copy_implementations)]
#[derive(Error, Debug, Clone)]
pub enum DocumentError {
#[error(transparent)]
GraphSortingError(#[from] crate::graph::GraphError),
#[error(transparent)]
DocumentViewError(#[from] DocumentViewError),
}
#[allow(missing_copy_implementations)]
#[derive(Error, Debug, Clone)]
pub enum DocumentViewError {
#[error("Operation must be instantiated from a CREATE operation")]
NotCreateOperation,
#[error("Operation passed to update() must be UPDATE or DELETE")]
NotUpdateOrDeleteOperation,
}
#[allow(missing_copy_implementations)]
#[derive(Error, Debug, Clone)]
pub enum DocumentViewIdError {
#[error("Expected sorted operation ids in document view id")]
UnsortedOperationIds,
#[error(transparent)]
InvalidOperationId(#[from] HashError),
#[error("Expected one or more operation ids")]
ZeroOperationIds,
}