solana-program-library/token-lending/program/src/error.rs

26 lines
674 B
Rust

//! Error types
use num_derive::FromPrimitive;
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
use thiserror::Error;
/// Errors that may be returned by the TokenLending program.
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum LendingError {
/// The account cannot be initialized because it is already being used.
#[error("Lending account already in use")]
AlreadyInUse,
}
impl From<LendingError> for ProgramError {
fn from(e: LendingError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for LendingError {
fn type_of() -> &'static str {
"Lending Error"
}
}