diff options
author | Teddy Wing | 2020-07-04 15:38:32 +0200 |
---|---|---|
committer | Teddy Wing | 2020-07-04 15:38:32 +0200 |
commit | 9b8f7dcaa4c3c054d4e3e1edc7e0780167d2a59a (patch) | |
tree | 8105394a1c0adb014f9a49c3c188a90874963b00 /src/request.rs | |
parent | b470de2c475940bd1bf7ade73e3b1c911be897e6 (diff) | |
download | fastcgi-conduit-9b8f7dcaa4c3c054d4e3e1edc7e0780167d2a59a.tar.bz2 |
request::Error: Remove context from error variants
Since we don't need to add any additional context or messages here, we
can turn off error context for these variants and shorten error
propagation.
Diffstat (limited to 'src/request.rs')
-rw-r--r-- | src/request.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/request.rs b/src/request.rs index dcc91a0..c10fc62 100644 --- a/src/request.rs +++ b/src/request.rs @@ -11,19 +11,19 @@ use snafu::{ResultExt, Snafu}; #[derive(Debug, Snafu)] pub enum Error { /// The HTTP method is invalid. - #[snafu(display("{}", source))] + #[snafu(context(false))] InvalidMethod { source: http::method::InvalidMethod }, /// An invalid HTTP header name. - #[snafu(display("{}", source))] + #[snafu(context(false))] InvalidHeaderName { source: conduit::header::InvalidHeaderName }, /// An invalid HTTP header value. - #[snafu(display("{}", source))] + #[snafu(context(false))] InvalidHeaderValue { source: conduit::header::InvalidHeaderValue }, /// An invalid remote address. - #[snafu(display("{}", source))] + #[snafu(context(false))] InvalidRemoteAddr { source: RemoteAddrError }, } @@ -72,11 +72,11 @@ impl<'a> FastCgiRequest<'a> { pub fn new(request: &'a mut fastcgi::Request) -> RequestResult<Self> { let version = Self::version(request); let host = Self::host(request); - let method = Self::method(request).context(InvalidMethod)?; + let method = Self::method(request)?; let headers = Self::headers(request.params())?; let path = Self::path(request); let query = Self::query(request); - let remote_addr = Self::remote_addr(request).context(InvalidRemoteAddr)?; + let remote_addr = Self::remote_addr(request)?; let content_length = Self::content_length(request); Ok(Self { @@ -144,10 +144,8 @@ impl<'a> FastCgiRequest<'a> { .map(|(name, value)| (name.as_bytes(), value.as_bytes())) { map.append( - conduit::header::HeaderName::from_bytes(name) - .context(InvalidHeaderName)?, - conduit::header::HeaderValue::from_bytes(value) - .context(InvalidHeaderValue)?, + conduit::header::HeaderName::from_bytes(name)?, + conduit::header::HeaderValue::from_bytes(value)?, ); } |