diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-08-26 18:48:40 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-26 18:48:40 -0700 |
commit | 7e4544158d16f65acb4c69a0d4566008f2030a43 (patch) | |
tree | 7861332587c9ce350195103a12a0bda504fbdd04 /src/lib.rs | |
parent | 13220ca46bbc9fd0001c1c942c3b7238e0f596ee (diff) | |
download | es-public-proxy-7e4544158d16f65acb4c69a0d4566008f2030a43.tar.gz es-public-proxy-7e4544158d16f65acb4c69a0d4566008f2030a43.zip |
improve error handling/responses/logging
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -37,6 +37,7 @@ impl ProxyConfig { #[derive(Debug)] pub enum ProxyError { HttpError(String), + UpstreamError(String), ParseError(String), UnknownIndex(String), NotSupported(String), @@ -46,6 +47,7 @@ impl ProxyError { pub fn http_status_code(&self) -> StatusCode { match self { ProxyError::HttpError(_) => StatusCode::BAD_REQUEST, + ProxyError::UpstreamError(_) => StatusCode::BAD_GATEWAY, ProxyError::ParseError(_) => StatusCode::BAD_REQUEST, ProxyError::UnknownIndex(_) => StatusCode::NOT_FOUND, ProxyError::NotSupported(_) => StatusCode::FORBIDDEN, @@ -55,6 +57,7 @@ impl ProxyError { pub fn to_json_value(&self) -> serde_json::Value { let (type_slug, reason) = match self { ProxyError::HttpError(s) => ("http-error", s.clone()), + ProxyError::UpstreamError(s) => ("upstream-error", s.clone()), ProxyError::ParseError(s) => ("parse-error", s.clone()), ProxyError::UnknownIndex(index) => ( "unknown-index", |