proofmode 0.9.0

Capture, share, and preserve verifiable photos and videos
Documentation
use thiserror::Error;

#[derive(Error, Debug, Clone)]
#[cfg_attr(feature = "wasm", derive(serde::Serialize))]
pub enum ProofModeError {
    #[error("IO error: {0}")]
    Io(String),

    #[error("Serialization error: {0}")]
    Serialization(String),

    #[error("Crypto error: {0}")]
    Crypto(String),

    #[error("PGP error: {0}")]
    Pgp(String),

    #[error("Proof not found: {0}")]
    ProofNotFound(String),

    #[error("Invalid proof: {0}")]
    InvalidProof(String),

    #[error("Storage error: {0}")]
    Storage(String),

    #[error("Configuration error: {0}")]
    Configuration(String),

    #[error("Check error: {0}")]
    CheckError(String),
}

impl From<std::io::Error> for ProofModeError {
    fn from(err: std::io::Error) -> Self {
        ProofModeError::Io(err.to_string())
    }
}

impl From<serde_json::Error> for ProofModeError {
    fn from(err: serde_json::Error) -> Self {
        ProofModeError::Serialization(err.to_string())
    }
}

#[cfg(feature = "wasm")]
impl From<ProofModeError> for wasm_bindgen::JsValue {
    fn from(err: ProofModeError) -> Self {
        wasm_bindgen::JsValue::from_str(&err.to_string())
    }
}

pub type Result<T> = std::result::Result<T, ProofModeError>;