use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("session identifier mismatch for incoming message")]
SessionIdMismatch,
#[error("session identifier required")]
SessionIdRequired,
#[error("signer is not a verifying party")]
NotVerifyingParty,
#[error("number of participants '{0}' does not match number of verifying keys '{1}'")]
ParticipantVerifierLength(usize, usize),
#[error(transparent)]
Json(#[from] serde_json::Error),
#[cfg(feature = "cggmp")]
#[error(transparent)]
Cggmp(#[from] crate::cggmp::Error),
#[cfg(feature = "frost-ed25519")]
#[error(transparent)]
Frost(#[from] crate::frost::Error),
#[error(transparent)]
Protocol(#[from] polysig_protocol::Error),
#[cfg(any(feature = "cggmp", feature = "ecdsa",))]
#[error(transparent)]
Ecdsa(#[from] k256::ecdsa::Error),
#[cfg(any(feature = "eddsa", feature = "schnorr"))]
#[error(transparent)]
Ed25519(#[from] Box<ed25519::Error>),
}
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
impl From<Error> for wasm_bindgen::JsValue {
fn from(value: Error) -> Self {
let s = value.to_string();
wasm_bindgen::JsValue::from_str(&s)
}
}