| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- use crate::{client, state};
- pub type Result<T> = std::result::Result<T, Error>;
- #[derive(Debug, Clone, thiserror::Error)]
- pub enum Error {
- #[error("io error: `{0:?}`")]
- Io(std::io::ErrorKind),
- #[error("Cannot find home directory")]
- PathNotFound,
- /// VarInt was encoded in a non-minimal way
- #[error("non-minimal varint")]
- NonMinimalVarInt,
- /// Parsing And Encode/Decode errors
- #[error("parse failed: `{0}`")]
- ParseFailed(&'static str),
- #[error(transparent)]
- ParseIntError(#[from] std::num::ParseIntError),
- #[error(transparent)]
- ParseBigIntError(#[from] num_bigint::ParseBigIntError),
- #[error(transparent)]
- ParseFloatError(#[from] std::num::ParseFloatError),
- #[error(transparent)]
- FromHexError(#[from] hex::FromHexError),
- #[error("Url parse error `{0}`")]
- UrlParseError(String),
- #[error("No url found")]
- NoUrlFound,
- #[error("Malformed packet")]
- MalformedPacket,
- #[error(transparent)]
- AddrParseError(#[from] std::net::AddrParseError),
- #[error(transparent)]
- Base58EncodeError(#[from] bs58::encode::Error),
- #[error(transparent)]
- Base58DecodeError(#[from] bs58::decode::Error),
- #[error(transparent)]
- Utf8Error(#[from] std::string::FromUtf8Error),
- #[error(transparent)]
- StrUtf8Error(#[from] std::str::Utf8Error),
- #[error("TryInto error")]
- TryIntoError,
- #[error("TryFrom error")]
- TryFromError,
- #[error(transparent)]
- TryFromBigIntError(#[from] num_bigint::TryFromBigIntError<num_bigint::BigUint>),
- #[error("Json serialization error: `{0}`")]
- SerdeJsonError(String),
- #[error(transparent)]
- TomlDeserializeError(#[from] toml::de::Error),
- #[error(transparent)]
- TomlSerializeError(#[from] toml::ser::Error),
- #[error("Bincode serialization error: `{0}`")]
- BincodeError(String),
- /// Contract
- #[error("Bad variable ref type byte")]
- BadVariableRefType,
- #[error("Bad operation type byte")]
- BadOperationType,
- #[error("Bad constraint type byte")]
- BadConstraintType,
- #[error("Invalid param name")]
- InvalidParamName,
- #[error("Invalid param type")]
- InvalidParamType,
- #[error("Missing params")]
- MissingParams,
- #[error("Contract is poorly defined")]
- BadContract,
- #[error("Operation failed")]
- OperationFailed,
- #[error("PLONK error: `{0}`")]
- PlonkError(String),
- #[error("Unable to decrypt mint note")]
- NoteDecryptionFailed,
- #[error(transparent)]
- VerifyFailed(#[from] state::VerifyFailed),
- #[error("MerkleTree is full")]
- TreeFull,
- /// Service
- #[error("Services Error: `{0}`")]
- ServicesError(&'static str),
- #[error("Client failed: `{0}`")]
- ClientFailed(String),
- #[cfg(feature = "btc")]
- #[error(transparent)]
- BtcFailed(#[from] crate::service::BtcFailed),
- #[cfg(feature = "sol")]
- #[error("Sol client failed: `{0}`")]
- SolFailed(String),
- #[cfg(feature = "eth")]
- #[error(transparent)]
- EthFailed(#[from] crate::service::EthFailed),
- #[error("BridgeError Error: `{0}`")]
- BridgeError(String),
- #[error("ZmqError: `{0}`")]
- ZmqError(String),
- /// Database/Sql errors
- #[error("Rocksdb error: `{0}`")]
- RocksdbError(String),
- #[error("sqlx error: `{0}`")]
- SqlxError(String),
- #[error("SlabsStore Error: `{0}`")]
- SlabsStore(String),
- /// RPC errors
- #[error("JsonRpc Error: `{0}`")]
- JsonRpcError(String),
- #[error("Not supported network")]
- NotSupportedNetwork,
- #[error("Not supported token")]
- NotSupportedToken,
- #[error("Could not parse token parameter")]
- TokenParseError,
- #[error("Cannot parse network parameter")]
- NetworkParseError,
- #[error("Async_Native_TLS error: `{0}`")]
- AsyncNativeTlsError(String),
- #[error("TungsteniteError: `{0}`")]
- TungsteniteError(String),
- /// Network
- #[error("Connection failed")]
- ConnectFailed,
- #[error("Connection timed out")]
- ConnectTimeout,
- #[error("Channel stopped")]
- ChannelStopped,
- #[error("Channel timed out")]
- ChannelTimeout,
- #[error("Service stopped")]
- ServiceStopped,
- /// Util
- #[error("No config file detected. Please create one.")]
- ConfigNotFound,
- #[error("No keypair file detected.")]
- KeypairPathNotFound,
- #[error("No cashier public keys detected.")]
- CashierKeysNotFound,
- #[error("SetLoggerError")]
- SetLoggerError,
- #[error("Async_channel sender error")]
- AsyncChannelSenderError,
- #[error(transparent)]
- AsyncChannelReceiverError(#[from] async_channel::RecvError),
- }
- impl From<zeromq::ZmqError> for Error {
- fn from(err: zeromq::ZmqError) -> Error {
- Error::ZmqError(err.to_string())
- }
- }
- impl From<rocksdb::Error> for Error {
- fn from(err: rocksdb::Error) -> Error {
- Error::RocksdbError(err.to_string())
- }
- }
- impl From<sqlx::error::Error> for Error {
- fn from(err: sqlx::error::Error) -> Error {
- Error::SqlxError(err.to_string())
- }
- }
- impl From<serde_json::Error> for Error {
- fn from(err: serde_json::Error) -> Error {
- Error::SerdeJsonError(err.to_string())
- }
- }
- impl From<std::io::Error> for Error {
- fn from(err: std::io::Error) -> Error {
- Error::Io(err.kind())
- }
- }
- impl<T> From<async_channel::SendError<T>> for Error {
- fn from(_err: async_channel::SendError<T>) -> Error {
- Error::AsyncChannelSenderError
- }
- }
- impl From<async_native_tls::Error> for Error {
- fn from(err: async_native_tls::Error) -> Error {
- Error::AsyncNativeTlsError(err.to_string())
- }
- }
- impl From<url::ParseError> for Error {
- fn from(err: url::ParseError) -> Error {
- Error::UrlParseError(err.to_string())
- }
- }
- impl From<client::ClientFailed> for Error {
- fn from(err: client::ClientFailed) -> Error {
- Error::ClientFailed(err.to_string())
- }
- }
- impl From<log::SetLoggerError> for Error {
- fn from(_err: log::SetLoggerError) -> Error {
- Error::SetLoggerError
- }
- }
- impl From<tungstenite::Error> for Error {
- fn from(err: tungstenite::Error) -> Error {
- Error::TungsteniteError(err.to_string())
- }
- }
- #[cfg(feature = "sol")]
- impl From<crate::service::SolFailed> for Error {
- fn from(err: crate::service::SolFailed) -> Error {
- Error::SolFailed(err.to_string())
- }
- }
- impl From<halo2::plonk::Error> for Error {
- fn from(err: halo2::plonk::Error) -> Error {
- Error::PlonkError(format!("{:?}", err))
- }
- }
- #[cfg(feature = "darkpulse")]
- impl From<rusqlite::Error> for Error {
- fn from(err: rusqlite::Error) -> Error {
- Error::SqlxError(err.to_string())
- }
- }
- impl From<Box<bincode::ErrorKind>> for Error {
- fn from(err: Box<bincode::ErrorKind>) -> Error {
- Error::BincodeError(err.to_string())
- }
- }
|