use crate::types::{
register::{EntryHash, User},
DataAddress,
};
use serde::{Deserialize, Serialize};
use std::result;
use thiserror::Error;
use xor_name::Prefix;
pub type Result<T, E = Error> = result::Result<T, E>;
#[derive(Error, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Error {
#[error("Access denied for user: {0:?}")]
AccessDenied(User),
#[error("Requested data not found: {0:?}")]
DataNotFound(DataAddress),
#[error("Failed to write file")]
FailedToWriteFile,
#[error("Failed to store data. Insufficient replication count at section {prefix:?}. Expected {expected}, found {found}.")]
InsufficientNodeCount {
prefix: Prefix,
expected: u8,
found: u8,
},
#[error("Requested entry not found {0}")]
NoSuchEntry(EntryHash),
#[error("Requested user not found {0:?}")]
NoSuchUser(User),
#[error("Invalid operation: {0}")]
InvalidOperation(String),
#[error("Spent proof is signed by section key {0:?} that is unknown to the current section")]
SpentProofUnknownSectionKey(bls::PublicKey),
#[error("Trying to produce a CmdResponse error for a data type not resulting from a cmd")]
NoCorrespondingCmdError,
}