Skip to content

Commit

Permalink
chore: avoid single char error bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Sep 3, 2023
1 parent d445742 commit 215a52f
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 73 deletions.
16 changes: 8 additions & 8 deletions actix-http/src/encoding/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},

#[cfg(feature = "compress-gzip")]
Expand All @@ -205,7 +205,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},

#[cfg(feature = "compress-gzip")]
Expand All @@ -218,7 +218,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},

#[cfg(feature = "compress-zstd")]
Expand All @@ -231,7 +231,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},
}
}
Expand All @@ -250,7 +250,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},

#[cfg(feature = "compress-gzip")]
Expand All @@ -265,7 +265,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},

#[cfg(feature = "compress-gzip")]
Expand All @@ -280,7 +280,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},

#[cfg(feature = "compress-zstd")]
Expand All @@ -295,7 +295,7 @@ impl ContentDecoder {
Ok(None)
}
}
Err(e) => Err(e),
Err(err) => Err(err),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/h1/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl Decoder for PayloadDecoder {
*state = match state.step(src, size, &mut buf) {
Poll::Pending => return Ok(None),
Poll::Ready(Ok(state)) => state,
Poll::Ready(Err(e)) => return Err(e),
Poll::Ready(Err(err)) => return Err(err),
};

if *state == ChunkedState::End {
Expand Down
6 changes: 3 additions & 3 deletions actix-http/src/responses/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ResponseBuilder {
Ok((key, value)) => {
parts.headers.insert(key, value);
}
Err(e) => self.err = Some(e.into()),
Err(err) => self.err = Some(err.into()),
};
}

Expand All @@ -119,7 +119,7 @@ impl ResponseBuilder {
if let Some(parts) = self.inner() {
match header.try_into_pair() {
Ok((key, value)) => parts.headers.append(key, value),
Err(e) => self.err = Some(e.into()),
Err(err) => self.err = Some(err.into()),
};
}

Expand Down Expand Up @@ -193,7 +193,7 @@ impl ResponseBuilder {
Ok(value) => {
parts.headers.insert(header::CONTENT_TYPE, value);
}
Err(e) => self.err = Some(e.into()),
Err(err) => self.err = Some(err.into()),
};
}
self
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/ws/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl Decoder for Codec {
}
}
Ok(None) => Ok(None),
Err(e) => Err(e),
Err(err) => Err(err),
}
}
}
2 changes: 1 addition & 1 deletion actix-http/tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async fn chunked_payload() {
.take_payload()
.map(|res| match res {
Ok(pl) => pl,
Err(e) => panic!("Error reading payload: {}", e),
Err(err) => panic!("Error reading payload: {err}"),
})
.fold(0usize, |acc, chunk| ready(acc + chunk.len()))
.map(|req_size| {
Expand Down
4 changes: 2 additions & 2 deletions actix-web-actors/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,10 @@ where
break;
}
Poll::Pending => break,
Poll::Ready(Some(Err(e))) => {
Poll::Ready(Some(Err(err))) => {
return Poll::Ready(Some(Err(ProtocolError::Io(io::Error::new(
io::ErrorKind::Other,
format!("{}", e),
format!("{err}"),
)))));
}
}
Expand Down
2 changes: 1 addition & 1 deletion actix-web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "actix-web"
version = "4.4.0"
description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
]
description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust"
keywords = ["actix", "http", "web", "framework", "async"]
categories = [
"network-programming",
Expand Down
4 changes: 2 additions & 2 deletions actix-web/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ where
let fut = data();
async move {
match fut.await {
Err(e) => {
log::error!("Can not construct data instance: {:?}", e);
Err(err) => {
log::error!("Can not construct data instance: {err:?}");
Err(())
}
Ok(data) => {
Expand Down
10 changes: 5 additions & 5 deletions actix-web/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ where
let res = ready!(this.fut.poll(cx));
match res {
Ok(t) => Poll::Ready(Ok(Some(t))),
Err(e) => {
log::debug!("Error for Option<T> extractor: {}", e.into());
Err(err) => {
log::debug!("Error for Option<T> extractor: {}", err.into());
Poll::Ready(Ok(None))
}
}
Expand Down Expand Up @@ -217,8 +217,8 @@ where
/// /// extract `Thing` from request
/// async fn index(supplied_thing: Result<Thing>) -> String {
/// match supplied_thing {
/// Ok(thing) => format!("Got thing: {:?}", thing),
/// Err(e) => format!("Error extracting thing: {}", e)
/// Ok(thing) => format!("Got thing: {thing:?}"),
/// Err(err) => format!("Error extracting thing: {err}"),
/// }
/// }
///
Expand Down Expand Up @@ -355,7 +355,7 @@ mod tuple_from_req {
Poll::Ready(Ok(output)) => {
let _ = this.$T.as_mut().project_replace(ExtractFuture::Done { output });
},
Poll::Ready(Err(e)) => return Poll::Ready(Err(e.into())),
Poll::Ready(Err(err)) => return Poll::Ready(Err(err.into())),
Poll::Pending => ready = false,
},
ExtractProj::Done { .. } => {},
Expand Down
2 changes: 1 addition & 1 deletion actix-web/src/middleware/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ where

let res = match ready!(this.fut.poll(cx)) {
Ok(res) => res,
Err(e) => return Poll::Ready(Err(e)),
Err(err) => return Poll::Ready(Err(err)),
};

if let Some(error) = res.response().error() {
Expand Down
6 changes: 3 additions & 3 deletions actix-web/src/response/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl HttpResponseBuilder {
Ok((key, value)) => {
parts.headers.insert(key, value);
}
Err(e) => self.error = Some(e.into()),
Err(err) => self.error = Some(err.into()),
};
}

Expand All @@ -86,7 +86,7 @@ impl HttpResponseBuilder {
if let Some(parts) = self.inner() {
match header.try_into_pair() {
Ok((key, value)) => parts.headers.append(key, value),
Err(e) => self.error = Some(e.into()),
Err(err) => self.error = Some(err.into()),
};
}

Expand Down Expand Up @@ -210,7 +210,7 @@ impl HttpResponseBuilder {
Ok(value) => {
parts.headers.insert(header::CONTENT_TYPE, value);
}
Err(e) => self.error = Some(e.into()),
Err(err) => self.error = Some(err.into()),
};
}
self
Expand Down
2 changes: 1 addition & 1 deletion actix-web/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ fn bind_addrs(addrs: impl net::ToSocketAddrs, backlog: u32) -> io::Result<Vec<ne
success = true;
sockets.push(lst);
}
Err(e) => err = Some(e),
Err(error) => err = Some(error),
}
}

Expand Down
6 changes: 3 additions & 3 deletions actix-web/src/types/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::{fmt, ops};

use actix_utils::future::{err, ok, Ready};
use actix_utils::future::{ready, Ready};

use crate::{
dev::Payload, error::ParseError, extract::FromRequest, http::header::Header as ParseHeader,
Expand Down Expand Up @@ -66,8 +66,8 @@ where
#[inline]
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future {
match ParseHeader::parse(req) {
Ok(header) => ok(Header(header)),
Err(e) => err(e),
Ok(header) => ready(Ok(Header(header))),
Err(err) => ready(Err(err)),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions awc/src/client/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,8 @@ mod resolver {
None => {
let (cfg, opts) = match read_system_conf() {
Ok((cfg, opts)) => (cfg, opts),
Err(e) => {
log::error!("TRust-DNS can not load system config: {}", e);
Err(err) => {
log::error!("Trust-DNS can not load system config: {err}");
(ResolverConfig::default(), ResolverOpts::default())
}
};
Expand Down
2 changes: 1 addition & 1 deletion awc/src/client/h1proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ where
headers.insert(HOST, value);
}
},
Err(e) => log::error!("Can not set HOST header {}", e),
Err(err) => log::error!("Can not set HOST header {err}"),
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions awc/src/client/h2proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ where
}

let res = poll_fn(|cx| io.poll_ready(cx)).await;
if let Err(e) = res {
io.on_release(e.is_io());
return Err(SendRequestError::from(e));
if let Err(err) = res {
io.on_release(err.is_io());
return Err(SendRequestError::from(err));
}

let resp = match io.send_request(req, eof) {
Expand All @@ -120,9 +120,9 @@ where
}
fut.await.map_err(SendRequestError::from)?
}
Err(e) => {
io.on_release(e.is_io());
return Err(e.into());
Err(err) => {
io.on_release(err.is_io());
return Err(err.into());
}
};

Expand Down Expand Up @@ -169,8 +169,8 @@ where
let len = b.len();
let bytes = b.split_to(std::cmp::min(cap, len));

if let Err(e) = send.send_data(bytes, false) {
return Err(e.into());
if let Err(err) = send.send_data(bytes, false) {
return Err(err.into());
}
if !b.is_empty() {
send.reserve_capacity(b.len());
Expand All @@ -179,7 +179,7 @@ where
}
continue;
}
Some(Err(e)) => return Err(e.into()),
Some(Err(err)) => return Err(err.into()),
}
}
}
Expand Down

0 comments on commit 215a52f

Please sign in to comment.