use crate::{storage::RegisterAddress, NetworkAddress, PrettyPrintRecordKey};
use serde::{Deserialize, Serialize};
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Clone, PartialEq, Eq, Serialize, Deserialize, custom_debug::Debug)]
#[non_exhaustive]
pub enum Error {
#[error("Chunk does not exist {0:?}")]
ChunkDoesNotExist(NetworkAddress),
#[error("Register not found: {0}")]
RegisterNotFound(Box<RegisterAddress>),
#[error("The Register was already created by another owner: {0:?}")]
RegisterAlreadyClaimed(bls::PublicKey),
#[error("There was an error getting the storecost from kademlia store")]
GetStoreCostFailed,
#[error("There was an error generating the payment quote")]
QuoteGenerationFailed,
#[error("Peer {holder:?} cannot find Record {key:?}")]
ReplicatedRecordNotFound {
holder: Box<NetworkAddress>,
key: Box<NetworkAddress>,
},
#[error("Could not Serialize/Deserialize RecordHeader to/from Record")]
RecordHeaderParsingFailed,
#[error("Could not Serialize/Deserialize Record")]
RecordParsingFailed,
#[error("The record already exists, so do not charge for it: {0:?}")]
RecordExists(PrettyPrintRecordKey<'static>),
}