use {
crate::models,
serde::{Deserialize, Serialize},
};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ExecutionStepError {
#[serde(rename = "INTERNAL_ERROR")]
InternalError,
#[serde(rename = "QUOTE_EXPIRED")]
QuoteExpired,
#[serde(rename = "INSUFFICIENT_OUTPUT_AMOUNT")]
InsufficientOutputAmount,
#[serde(rename = "INSUFFICIENT_FUNDS")]
InsufficientFunds,
#[serde(rename = "LAST_TRANSACTION_FAILED")]
LastTransactionFailed,
#[serde(rename = "SWAP_APPROVAL_FAILED")]
SwapApprovalFailed,
#[serde(rename = "PROVIDER_EXECUTION_ERROR")]
ProviderExecutionError,
}
impl std::fmt::Display for ExecutionStepError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::InternalError => write!(f, "INTERNAL_ERROR"),
Self::QuoteExpired => write!(f, "QUOTE_EXPIRED"),
Self::InsufficientOutputAmount => write!(f, "INSUFFICIENT_OUTPUT_AMOUNT"),
Self::InsufficientFunds => write!(f, "INSUFFICIENT_FUNDS"),
Self::LastTransactionFailed => write!(f, "LAST_TRANSACTION_FAILED"),
Self::SwapApprovalFailed => write!(f, "SWAP_APPROVAL_FAILED"),
Self::ProviderExecutionError => write!(f, "PROVIDER_EXECUTION_ERROR"),
}
}
}
impl Default for ExecutionStepError {
fn default() -> ExecutionStepError {
Self::InternalError
}
}