Skip to content

Commit

Permalink
refactor: write error variable name longer
Browse files Browse the repository at this point in the history
while error is nicer, err prevents another line break so its sometimes preferred
  • Loading branch information
EdJoPaTo committed Sep 10, 2024
1 parent 6c5e900 commit 8d419b1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions examples/reply_to_message_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ fn main() {
let reply_parameters = ReplyParameters::builder()
.message_id(message.message_id)
.build();

let send_message_params = SendMessageParams::builder()
.chat_id(message.chat.id)
.text("hello")
.reply_parameters(reply_parameters)
.build();

if let Err(err) = api.send_message(&send_message_params) {
println!("Failed to send message: {err:?}");
if let Err(error) = api.send_message(&send_message_params) {
println!("Failed to send message: {error:?}");
}
}
update_params.offset = Some(i64::from(update.update_id) + 1);
Expand Down
4 changes: 2 additions & 2 deletions src/client_reqwest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl AsyncApi {
where
Params: serde::ser::Serialize + std::fmt::Debug,
{
serde_json::to_string(params).map_err(|e| Error::Encode(format!("{e:?} : {params:?}")))
serde_json::to_string(params).map_err(|err| Error::Encode(format!("{err:?} : {params:?}")))
}

pub async fn decode_response<Output>(response: reqwest::Response) -> Result<Output, Error>
Expand All @@ -55,7 +55,7 @@ impl AsyncApi {
}

fn parse_json<Output: serde::de::DeserializeOwned>(body: &str) -> Result<Output, Error> {
serde_json::from_str(body).map_err(|e| Error::Decode(format!("{e:?} : {body:?}")))
serde_json::from_str(body).map_err(|error| Error::Decode(format!("{error:?} : {body:?}")))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/client_ureq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Api {
where
Params: serde::ser::Serialize + std::fmt::Debug,
{
serde_json::to_string(params).map_err(|e| Error::Encode(format!("{e:?} : {params:?}")))
serde_json::to_string(params).map_err(|err| Error::Encode(format!("{err:?} : {params:?}")))
}

pub fn decode_response<Output>(response: Response) -> Result<Output, Error>
Expand All @@ -41,7 +41,7 @@ impl Api {
match response.into_string() {
Ok(message) => serde_json::from_str(&message)
.map_err(|error| Error::Decode(format!("{error:?} : {message:?}"))),
Err(e) => Err(Error::Decode(format!("Failed to decode response: {e:?}"))),
Err(err) => Err(Error::Decode(format!("Failed to decode response: {err:?}"))),
}
}
}
Expand Down

0 comments on commit 8d419b1

Please sign in to comment.