use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Assertion failed: {0}")]
AssertionFailed(String),
#[error("Bad Encrypted Message")]
BadEncryptedMessage,
#[error("Bad Encrypted Message due to invalid base64")]
BadEncryptedMessageBase64(base64::DecodeError),
#[error("Base64 Decoding Error: {0}")]
Base64(#[from] base64::DecodeError),
#[error("Bech32 Error: {0}")]
Bech32Decode(#[from] bech32::DecodeError),
#[error("Bech32 Error: {0}")]
Bech32Encode(#[from] bech32::EncodeError),
#[error("Bech32 Error: {0}")]
Bech32Hrp(#[from] bech32::primitives::hrp::Error),
#[error("Crypto Error: {0}")]
Crypto(#[from] nip44::Error),
#[error("Private Key Encryption/Decryption Error")]
PrivateKeyEncryption,
#[error("From UTF-8 Error")]
FromUtf8(#[from] std::string::FromUtf8Error),
#[error("Wrong Bech32 Kind: Expected {0} found {0}")]
WrongBech32(String, String),
#[error("Key or Signature Error: {0}")]
KeyOrSignature(#[from] secp256k1::Error),
#[error("Event is in the future")]
EventInFuture,
#[error("Formatting Error: {0}")]
Fmt(#[from] std::fmt::Error),
#[error("Hash Mismatch")]
HashMismatch,
#[error("Hex Decode Error: {0}")]
HexDecode(#[from] hex::FromHexError),
#[error("Invalid Encrypted Private Key")]
InvalidEncryptedPrivateKey,
#[error("Invalid Encrypted Event")]
InvalidEncryptedEvent,
#[error("Invalid event Id")]
InvalidId,
#[error("Invalid event Id Prefix")]
InvalidIdPrefix,
#[error("Invalid digest length")]
InvalidLength(#[from] hmac::digest::InvalidLength),
#[error("Invalid naddr")]
InvalidNAddr,
#[error("Invalid nevent")]
InvalidNEvent,
#[error("Invalid Operation")]
InvalidOperation,
#[error("Invalid Private Key")]
InvalidPrivateKey,
#[error("Invalid Profile")]
InvalidProfile,
#[error("Invalid Public Key")]
InvalidPublicKey,
#[error("Invalid Public Key Prefix")]
InvalidPublicKeyPrefix,
#[error("Invalid Recipient")]
InvalidRecipient,
#[error("Invalid URL: \"{0}\"")]
InvalidUrl(#[from] url::ParseError),
#[error("Invalid URL TLV encoding")]
InvalidUrlTlv,
#[error("Invalid URL Host: \"{0}\"")]
InvalidUrlHost(String),
#[error("Invalid URL Scheme: \"{0}\"")]
InvalidUrlScheme(String),
#[error("Missing URL Authority")]
InvalidUrlMissingAuthority,
#[error("Event kind is not replaceable")]
NonReplaceableAddr,
#[error("No private key")]
NoPrivateKey,
#[error("No public key")]
NoPublicKey,
#[error("Out of Range")]
OutOfRange(usize),
#[error("Parse integer error")]
ParseInt(#[from] std::num::ParseIntError),
#[error("Scrypt invalid output length")]
Scrypt,
#[error("JSON (de)serialization error: {0}")]
SerdeJson(#[from] serde_json::Error),
#[error("Signer is locked")]
SignerIsLocked,
#[error("Try From Slice error: {0}")]
Slice(#[from] std::array::TryFromSliceError),
#[cfg(feature = "speedy")]
#[error("Speedy (de)serialization error: {0}")]
Speedy(#[from] speedy::Error),
#[error("Tag mismatch")]
TagMismatch,
#[error("Unknown event kind = {0}")]
UnknownEventKind(u32),
#[error("Unknown key security = {0}")]
UnknownKeySecurity(u8),
#[error("Unknown cipher version = {0}")]
UnknownCipherVersion(u8),
#[error("Decryption error: {0}")]
Unpad(#[from] aes::cipher::block_padding::UnpadError),
#[error("Not a valid nostr relay url: {0}")]
Url(String),
#[error("UTF-8 Error: {0}")]
Utf8Error(#[from] std::str::Utf8Error),
#[error("Wrong event kind")]
WrongEventKind,
#[error("Wrong length hex string")]
WrongLengthHexString,
#[error("Wrong length bytes for event kind")]
WrongLengthKindBytes,
#[error("Wrong decryption password")]
WrongDecryptionPassword,
#[error("Invalid Zap Receipt: {0}")]
ZapReceipt(String),
}