#[derive(thiserror::Error, miette::Diagnostic, Debug)]
pub enum Error {
#[error("HTTP error: {_0}")]
#[diagnostic(help = "an http error ocurred. check your internet connection, and try again.")]
Http(
#[from]
#[source]
reqwest::Error,
),
#[error("API error: {_0}")]
#[diagnostic(transparent)]
Api(
#[from]
#[source]
#[diagnostic_source]
ApiError,
),
}
#[derive(thiserror::Error, miette::Diagnostic, Debug)]
pub enum ApiError {
#[error("you weren't authorized to use that endpoint")]
#[diagnostic(help = "try to log in with `fjo auth login`")]
Unauthorized,
#[error("the requested resource was not found")]
#[diagnostic(help = "are you sure you didn't make a typo?")]
NotFound,
#[error(transparent)]
#[diagnostic(transparent)]
Forbidden(
#[from]
#[diagnostic_source]
ForbiddenError,
),
}
#[derive(thiserror::Error, miette::Diagnostic, Debug, serde::Deserialize, serde::Serialize)]
#[error("your account is not allowed to perform that operation")]
pub struct ForbiddenError {
#[source_code]
pub message: String,
pub url: String,
}
pub type Result<T, E = Error> = core::result::Result<T, E>;