use mystem::AppError as mystem_error; use reqwest::Error as reqwest_error; use rusqlite::Error as sqlite_error; use serde_json::Error as serde_error; use std::{fmt, io::Error as io_error}; use subprocess::PopenError as popen_error; use telegram_bot::Error as tg_error; #[derive(Debug)] pub enum Error { UserNotFound, SQLITE3Error(sqlite_error), TelegramError(tg_error), ReqwestError(reqwest_error), ConfNotFound, WordNotFound, WordInStopList, IOError(io_error), FileNotFound, JsonParseError(serde_error), PopenError(popen_error), MystemError(mystem_error), SQLBannedCommand(String), SQLInvalidCommand, SQLResultTooLong(String), CodeHighlightningError, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "An error occurred.") // match self { // _ => write!(f, "An error occurred."), // // Error::UserNotFound => {} // // Error::SQLITE3Error(_) => {} // // Error::TelegramError(_) => {} // // Error::ReqwestError(_) => {} // // Error::ConfNotFound => {} // // Error::WordNotFound => {} // // Error::WordInStopList => {} // // Error::IOError(_) => {} // // Error::FileNotFound => {} // // Error::JsonParseError(_) => {} // // Error::PopenError(_) => {} // // Error::MystemError(_) => {} // // Error::SQLBannedCommand(_) => {} // // Error::SQLInvalidCommand => {} // // Error::SQLResultTooLong(_) => {} // // Error::CodeHighlightningError(Help) => write!(f, "Code highlighter.\ // // Usage
/CODE\ // // #<theme>\ // // <CODE>\ // // #<lang>\ // // \ // // List of themes:\ // // .") // Error::CodeHighlightningError(help) => write!(f, "{}", help.description) // } } } impl From