#[non_exhaustive]
#[derive(thiserror::Error, Debug)]
pub enum PassthroughError {
#[error("Upstream request failed: {0}")]
Http(#[from] reqwest::Error),
#[error("Passthrough upstream has no URL templates configured")]
EmptyUrlList,
#[error("Invalid header name {name:?} for passthrough upstream: {source}")]
InvalidHeaderName {
name: String,
#[source]
source: reqwest::header::InvalidHeaderName,
},
#[error("Invalid value for header {name:?} for passthrough upstream: {source}")]
InvalidHeaderValue {
name: String,
#[source]
source: reqwest::header::InvalidHeaderValue,
},
#[error("Tile URL template {0} must contain {{z}}, {{x}} and {{y}} placeholders")]
InvalidUrlTemplate(String),
#[error("Failed to fetch TileJSON from {url}: {source}")]
TileJsonFetch {
url: String,
#[source]
source: reqwest::Error,
},
#[error("Fetching TileJSON from {url} returned HTTP status {status}")]
TileJsonStatus {
url: String,
status: u16,
},
#[error("Failed to parse TileJSON from {url}: {source}")]
TileJsonParse {
url: String,
#[source]
source: serde_json::Error,
},
#[error("TileJSON from {0} contained no tile URL templates")]
NoTilesInTileJson(String),
#[error(
"Cannot determine tile format for passthrough source {0}; set `format` explicitly in the config"
)]
FormatUndeterminable(String),
#[error("Upstream {url} returned unexpected HTTP status {status}")]
UnexpectedStatus {
url: String,
status: u16,
},
}
impl crate::Classify for PassthroughError {
fn kind(&self) -> crate::ErrorKind {
use crate::ErrorKind::{Internal, Unavailable};
match self {
Self::Http(_)
| Self::TileJsonFetch { .. }
| Self::TileJsonStatus { .. }
| Self::TileJsonParse { .. }
| Self::UnexpectedStatus { .. } => Unavailable,
Self::EmptyUrlList
| Self::InvalidHeaderName { .. }
| Self::InvalidHeaderValue { .. }
| Self::InvalidUrlTemplate(_)
| Self::NoTilesInTileJson(_)
| Self::FormatUndeterminable(_) => Internal,
}
}
}