martin_core/tiles/passthrough/
error.rs1#[non_exhaustive]
5#[derive(thiserror::Error, Debug)]
6pub enum PassthroughError {
7 #[error("Upstream request failed: {0}")]
9 Http(#[from] reqwest::Error),
10
11 #[error("Passthrough upstream has no URL templates configured")]
13 EmptyUrlList,
14
15 #[error("Invalid header name {name:?} for passthrough upstream: {source}")]
17 InvalidHeaderName {
18 name: String,
20 #[source]
22 source: reqwest::header::InvalidHeaderName,
23 },
24
25 #[error("Invalid value for header {name:?} for passthrough upstream: {source}")]
27 InvalidHeaderValue {
28 name: String,
30 #[source]
32 source: reqwest::header::InvalidHeaderValue,
33 },
34
35 #[error("Tile URL template {0} must contain {{z}}, {{x}} and {{y}} placeholders")]
37 InvalidUrlTemplate(String),
38
39 #[error("Failed to fetch TileJSON from {url}: {source}")]
41 TileJsonFetch {
42 url: String,
44 #[source]
46 source: reqwest::Error,
47 },
48
49 #[error("Fetching TileJSON from {url} returned HTTP status {status}")]
51 TileJsonStatus {
52 url: String,
54 status: u16,
56 },
57
58 #[error("Failed to parse TileJSON from {url}: {source}")]
60 TileJsonParse {
61 url: String,
63 #[source]
65 source: serde_json::Error,
66 },
67
68 #[error("TileJSON from {0} contained no tile URL templates")]
70 NoTilesInTileJson(String),
71
72 #[error(
74 "Cannot determine tile format for passthrough source {0}; set `format` explicitly in the config"
75 )]
76 FormatUndeterminable(String),
77
78 #[error("Upstream {url} returned unexpected HTTP status {status}")]
80 UnexpectedStatus {
81 url: String,
83 status: u16,
85 },
86}
87
88impl crate::Classify for PassthroughError {
89 fn kind(&self) -> crate::ErrorKind {
90 use crate::ErrorKind::{Internal, Unavailable};
91 match self {
92 Self::Http(_)
93 | Self::TileJsonFetch { .. }
94 | Self::TileJsonStatus { .. }
95 | Self::TileJsonParse { .. }
96 | Self::UnexpectedStatus { .. } => Unavailable,
97 Self::EmptyUrlList
98 | Self::InvalidHeaderName { .. }
99 | Self::InvalidHeaderValue { .. }
100 | Self::InvalidUrlTemplate(_)
101 | Self::NoTilesInTileJson(_)
102 | Self::FormatUndeterminable(_) => Internal,
103 }
104 }
105}