Something went wrong. Try again.
A Discord/Fluxer Bot connected to your Pterodactyl API.
Something went wrong. Try again.
1.2 kB · 41 lines
Rust
at v2
1234567891011121314151617181920212223242526272829303132333435363738394041use std::fmt;
#[derive(Debug)]pub enum Error { Request(reqwest::Error), InvalidApiKey, Api { code: String, status: String, detail: String }, RateLimited { retry_after_secs: u64 }, UnexpectedResponse(String),}
impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Request(e) => write!(f, "request failed: {e}"), Self::InvalidApiKey => write!(f, "invalid api key"), Self::Api { code, status, detail } => { write!(f, "api error [{code}] ({status}): {detail}") } Self::RateLimited { retry_after_secs } => { write!(f, "rate limited, retry after {retry_after_secs}s") } Self::UnexpectedResponse(s) => write!(f, "unexpected response shape: {s}"), } }}
impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Self::Request(e) => Some(e), _ => None, } }}
impl From<reqwest::Error> for Error { fn from(e: reqwest::Error) -> Self { Self::Request(e) }}