1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
use reqwest; use serde_json; /// The error type for any issues occuring while interacting with the Groupme API. #[derive(Debug)] pub enum GroupmeError { /// Caused by calling a method that requires an API token without providing one. /// /// When managing bots (creating or deleting) make sure to provide the /// `Groupme` a valid token. NoTokenError, /// Any request that caused the API to return a header caused by bad /// authentication with the Groupme API. /// /// This is usually caused by an invalid API token or bad bot_id. AuthError, /// The API returned an unexpected HTTP header. /// /// This is usually caused by not defining a proper bot_id or group_id. BadHeaderError(reqwest::StatusCode), /// Error communicating with the API. ReqwestError(reqwest::Error), /// Error parsing returned JSON values. SerdeError(serde_json::Error), /// Caused by an issue with interacting with the data returned from the API. /// /// This is used when JSON data is parsed but is not valid. GenericError, } impl From<reqwest::Error> for GroupmeError { fn from(error: reqwest::Error) -> Self { GroupmeError::ReqwestError(error) } } impl From<serde_json::Error> for GroupmeError { fn from(error: serde_json::Error) -> Self { GroupmeError::SerdeError(error) } }