use crate::prelude::*;

#[derive(thiserror::Error, Debug)]
enum Error {
    #[error("Failed to parse log directive: `{0}`")]
    LogParse(#[from] tracing_subscriber::filter::ParseError),
    #[error("I/O error: `{0}`")]
    Io(#[from] std::io::Error),
    #[error("RPC error: `{0}`")]
    RpcError(#[from] jsonrpsee::core::ClientError),
    #[error("subxt error: `{0}`")]
    Subxt(#[from] subxt::Error),
    #[error("Crypto error: `{0}`")]
    Crypto(sp_core::crypto::SecretStringError),
    #[error("Codec error: `{0}`")]
    Codec(#[from] codec::Error),
    #[error("Incorrect phase")]
    IncorrectPhase,
    #[error("Submission is already submitted")]
    AlreadySubmitted,
    #[error("The account does not exist")]
    AccountDoesNotExist,
    #[error("Submission with better score already exist")]
    BetterScoreExist,
    #[error("Invalid chain: `{0}`, staking-miner supports only ghost and casper")]
    InvalidChain(String),
    #[error("Other error: `{0}`")]
    Other(String),
    #[error("Invalid metadata: `{0}`")]
    InvalidMetadata(String),
    #[error("Transaction rejected: `{0}`")]
    TransactionRejected(String),
    #[error("Dynamic transaction error: `{0}`")]
    DynamicTransaction(String),
    #[error("Feasibility error: `{0}`")]
    Feasibility(String),
    #[error("{0}")]
    JoinError(#[from] tokio::task::JoinError),
    #[error("Empty snapshot")]
    EmptySnapshot,
}
