use abi_stable::{ std_types::{ RBoxError, RVec}, StableAbi, }; use std::{ error::Error as ErrorTrait, fmt::{self, Display}, }; #[repr(u8)] #[derive(Debug, StableAbi)] pub enum Error { UnsupportedFormat, FileError(RBoxError), Custom(RBoxError), /// A list of errors. Many(RVec), } impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Error::UnsupportedFormat => { writeln!( f, "Plugin ooes not support this command:\n\ \t\n\ Because of this error:\n\n\ Supported commands:\ " )?; Ok(()) }, Error::Custom(e) => Display::fmt(e, f), Error::Many(list) => { for e in list { writeln!(f, "{}", e)?; } Ok(()) }, _ => { Ok(())} } } } impl ErrorTrait for Error {}