From 7e4544158d16f65acb4c69a0d4566008f2030a43 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 26 Aug 2020 18:48:40 -0700 Subject: improve error handling/responses/logging --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/lib.rs') 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", -- cgit v1.2.3