2022-07-21 13:46:49 +10:00
|
|
|
#[derive(Debug, thiserror::Error, miette::Diagnostic)]
|
|
|
|
pub enum TeslatteError {
|
|
|
|
#[error("{request} server error: {msg}: {description:?}")]
|
|
|
|
#[diagnostic()]
|
|
|
|
ServerError {
|
|
|
|
request: String,
|
|
|
|
msg: String,
|
|
|
|
description: Option<String>,
|
2023-08-29 16:13:43 +10:00
|
|
|
body: Option<String>,
|
2022-07-21 13:46:49 +10:00
|
|
|
},
|
|
|
|
|
|
|
|
#[error("{request} unhandled server response: {body}")]
|
|
|
|
#[diagnostic()]
|
|
|
|
UnhandledServerError { request: String, body: String },
|
|
|
|
|
|
|
|
#[error("{request} fetch error")]
|
|
|
|
#[diagnostic()]
|
|
|
|
FetchError {
|
|
|
|
source: reqwest::Error,
|
|
|
|
request: String,
|
|
|
|
},
|
|
|
|
|
|
|
|
#[error("{request} json decode error: {body}")]
|
|
|
|
#[diagnostic()]
|
|
|
|
DecodeJsonError {
|
|
|
|
source: serde_json::Error,
|
|
|
|
request: String,
|
|
|
|
body: String,
|
|
|
|
},
|
|
|
|
|
|
|
|
#[error("Unhandled reqwest error.")]
|
|
|
|
UnhandledReqwestError(#[source] reqwest::Error),
|
|
|
|
|
|
|
|
#[error("Did not supply a valid callback URL.")]
|
|
|
|
UserDidNotSupplyValidCallbackUrl(#[source] url::ParseError),
|
|
|
|
|
|
|
|
#[error("Callback URL did not contain a callback code.")]
|
|
|
|
CouldNotFindCallbackCode,
|
2022-07-24 13:00:05 +10:00
|
|
|
|
2023-08-29 11:57:36 +10:00
|
|
|
#[error("Callback URL did not contain the state.")]
|
|
|
|
CouldNotFindState,
|
|
|
|
|
|
|
|
#[error(
|
|
|
|
"State in the callback URL did not match the state in the request: {request} != {callback}"
|
|
|
|
)]
|
|
|
|
StateMismatch { request: String, callback: String },
|
|
|
|
|
2022-07-24 13:00:05 +10:00
|
|
|
#[error("Could not convert \"{0}\" to an EnergySiteId.")]
|
|
|
|
DecodeEnergySiteIdError(String),
|
2022-07-25 14:17:49 +10:00
|
|
|
|
|
|
|
#[error("No refresh token available.")]
|
|
|
|
NoRefreshToken,
|
2022-07-21 13:46:49 +10:00
|
|
|
}
|