use crate::document::{DocumentId, DocumentViewId};
use crate::entry::{EntryError, EntrySignedError, LogIdError, SeqNumError};
use crate::hash::{Hash, HashError};
use crate::identity::AuthorError;
use crate::operation::{OperationEncodedError, OperationError, OperationId};
#[derive(thiserror::Error, Debug)]
pub enum ValidationError {
#[error(transparent)]
AuthorValidation(#[from] AuthorError),
#[error(transparent)]
HashValidation(#[from] HashError),
#[error(transparent)]
EntryValidation(#[from] EntryError),
#[error(transparent)]
EntrySignedValidation(#[from] EntrySignedError),
#[error(transparent)]
OperationValidation(#[from] OperationError),
#[error(transparent)]
OperationEncodedValidation(#[from] OperationEncodedError),
#[error(transparent)]
LogIdValidation(#[from] LogIdError),
#[error(transparent)]
SeqNumValidation(#[from] SeqNumError),
#[error(transparent)]
BambooValidation(#[from] bamboo_rs_core_ed25519_yasmf::verify::Error),
}
#[derive(thiserror::Error, Debug)]
pub enum LogStorageError {
#[error("Error occured during `LogStorage` request in storage provider: {0}")]
Custom(String),
}
#[derive(thiserror::Error, Debug)]
pub enum EntryStorageError {
#[error("Error occured during `EntryStorage` request in storage provider: {0}")]
Custom(String),
#[error("Could not find expected backlink in database for entry with id: {0}")]
ExpectedBacklinkMissing(Hash),
#[error(
"The backlink hash encoded in the entry: {0} did not match the expected backlink hash"
)]
InvalidBacklinkPassed(Hash),
#[error("Could not find expected skiplink in database for entry with id: {0}")]
ExpectedSkiplinkMissing(Hash),
#[error("The skiplink hash encoded in the entry: {0} did not match the known hash of the skiplink target")]
InvalidSkiplinkPassed(Hash),
#[error("Could not find expected skiplink entry in database")]
ExpectedNextSkiplinkMissing,
#[error("Entry required for requested certificate pool missing at seq num: {0}")]
CertPoolEntryMissing(u64),
#[error(transparent)]
ValidationError(#[from] ValidationError),
}
#[derive(thiserror::Error, Debug)]
pub enum PublishEntryError {
#[error("Could not find document for entry in database with id: {0}")]
DocumentMissing(Hash),
#[error("UPDATE or DELETE operation with id: with id: {0} came without previous_operations")]
OperationWithoutPreviousOperations(OperationId),
#[error("Requested log id {0} does not match expected log id {1}")]
InvalidLogId(u64, u64),
#[error("Invalid Entry and Operation pair with id {0}")]
InvalidEntryWithOperation(Hash),
}
#[derive(thiserror::Error, Debug)]
pub enum OperationStorageError {
#[error("Error occured in OperationStore: {0}")]
Custom(String),
#[error("A fatal error occured in OperationStore: {0}")]
FatalStorageError(String),
#[error("Error occured when inserting an operation with id {0:?} into storage")]
InsertionError(OperationId),
}
#[derive(thiserror::Error, Debug)]
pub enum DocumentStorageError {
#[allow(dead_code)]
#[error("Error occured in DocumentStore: {0}")]
Custom(String),
#[error("A fatal error occured in DocumentStore: {0}")]
FatalStorageError(String),
#[error("Error occured when inserting a document view with id {0:?} into storage")]
DocumentViewInsertionError(DocumentViewId),
#[error("Error occured when inserting a document with id {0:?} into storage")]
DocumentInsertionError(DocumentId),
}