gpl_governance_tools/
error.rs1use num_derive::FromPrimitive;
4use gemachain_program::{
5 decode_error::DecodeError,
6 msg,
7 program_error::{PrintProgramError, ProgramError},
8};
9use thiserror::Error;
10
11#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
13pub enum GovernanceToolsError {
14 #[error("Account already initialized")]
16 AccountAlreadyInitialized = 1100,
17
18 #[error("Account doesn't exist")]
20 AccountDoesNotExist,
21
22 #[error("Invalid account owner")]
24 InvalidAccountOwner,
25
26 #[error("Invalid Account type")]
28 InvalidAccountType,
29}
30
31impl PrintProgramError for GovernanceToolsError {
32 fn print<E>(&self) {
33 msg!("GOVERNANCE-TOOLS-ERROR: {}", &self.to_string());
34 }
35}
36
37impl From<GovernanceToolsError> for ProgramError {
38 fn from(e: GovernanceToolsError) -> Self {
39 ProgramError::Custom(e as u32)
40 }
41}
42
43impl<T> DecodeError<T> for GovernanceToolsError {
44 fn type_of() -> &'static str {
45 "Governance Tools Error"
46 }
47}