aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-08-26 18:48:40 -0700
committerBryan Newbold <bnewbold@archive.org>2020-08-26 18:48:40 -0700
commit7e4544158d16f65acb4c69a0d4566008f2030a43 (patch)
tree7861332587c9ce350195103a12a0bda504fbdd04 /src/lib.rs
parent13220ca46bbc9fd0001c1c942c3b7238e0f596ee (diff)
downloades-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.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9093b24..9145fb1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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",