use hex::error::HexToBytesError;
use thiserror::Error;
use crate::DescriptorType;
#[cfg(feature = "address")]
use bitcoin::script::witness_program::Error as WitnessProgramError;
#[cfg(feature = "address")]
use bitcoin::secp256k1::Error as Secp256k1Error;
#[derive(Error, Debug, PartialEq, Eq)]
pub enum DescriptorError {
#[error("missing type tag")]
MissingTypeTag,
#[error("invalid descriptor type tag: {0}")]
InvalidDescriptorType(u8),
#[error("invalid payload length: {0}")]
InvalidPayloadLength(usize),
#[error("hex decoding error: {0}")]
HexDecodingError(#[from] HexToBytesError),
#[cfg(feature = "address")]
#[error("{0:?} cannot be converted to a bitcoin address")]
InvalidAddressConversion(DescriptorType),
#[cfg(feature = "address")]
#[error("secp256k1 error: {0}")]
Secp256k1Error(#[from] Secp256k1Error),
#[cfg(feature = "address")]
#[error("witness program error: {0}")]
WitnessProgramError(#[from] WitnessProgramError),
}