use holo_hash::{DnaHash, WasmHash};
use holochain_zome_types::zome::error::ZomeError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum DnaError {
#[error("Zome has no code: {0}")]
EmptyZome(String),
#[error("DNA is invalid: {0}")]
Invalid(String),
#[error("The DNA of the following hash was not found in the store: {0}")]
DnaMissing(DnaHash),
#[error("Trait not found: {0}")]
TraitNotFound(String),
#[error("Zome function not found: {0}")]
ZomeFunctionNotFound(String),
#[error(transparent)]
MrBundleError(#[from] mr_bundle::error::MrBundleError),
#[error(transparent)]
YamlSerializationError(#[from] serde_yaml::Error),
#[error(transparent)]
SerializedBytesError(#[from] holochain_serialized_bytes::SerializedBytesError),
#[error(transparent)]
ZomeError(#[from] ZomeError),
#[error("std::io::Error: {0}")]
StdIoError(String),
#[error("InvalidWasmHash")]
InvalidWasmHash,
#[error("DNA file hash mismatch.\nExpected: {0}\nActual: {1}")]
DnaHashMismatch(DnaHash, DnaHash),
#[error("Wasm hash mismatch.\nExpected: {0}\nActual: {1}")]
WasmHashMismatch(WasmHash, WasmHash),
#[error("Error converting DnaFile to DnaBundle: {0}")]
DnaFileToBundleConversionError(String),
#[error("All zome names must be unique within a DNA. Found duplicate: {0}")]
DuplicateZomeNames(String),
#[error("Zome dependency {0} for {1} is not pointing at an existing integrity zome that is not itself")]
DanglingZomeDependency(String, String),
}
impl From<std::io::Error> for DnaError {
fn from(error: std::io::Error) -> Self {
Self::StdIoError(error.to_string())
}
}
pub type DnaResult<T> = Result<T, DnaError>;