Skip to content

Commit

Permalink
fix: do not explicitly call description on nss error
Browse files Browse the repository at this point in the history
As in the documentation:
/// If you only need description in `println`, `format`, `log` and other
/// formatting contexts, you may want to use `Display` impl for `Code`
/// instead.

So, let’s use the display trait as the error macro is using format.
    /// If you only need description in `println`, `format`, `log` and other
    /// formatting contexts, you may want to use `Display` impl for `Code`
    /// instead.
  • Loading branch information
didrocks committed Jul 3, 2024
1 parent dd7d4ce commit 314ccc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
8 changes: 2 additions & 6 deletions nss/src/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn get_all_entries() -> Response<Vec<Group>> {
match client.get_group_entries(req).await {
Ok(r) => Response::Success(group_entries_to_groups(r.into_inner().entries)),
Err(e) => {
error!("error when listing groups: {}", e.code().description());
error!("error when listing groups: {}", e.code());
super::grpc_status_to_nss_response(e)
}
}
Expand Down Expand Up @@ -81,11 +81,7 @@ fn get_entry_by_gid(gid: gid_t) -> Response<Group> {
match client.get_group_by_gid(req).await {
Ok(r) => Response::Success(group_entry_to_group(r.into_inner())),
Err(e) => {
error!(
"error when getting group by gid '{}': {}",
gid,
e.code().description()
);
error!("error when getting group by gid '{}': {}", gid, e.code());
super::grpc_status_to_nss_response(e)
}
}
Expand Down
10 changes: 3 additions & 7 deletions nss/src/passwd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn get_all_entries() -> Response<Vec<Passwd>> {
match client.get_passwd_entries(req).await {
Ok(r) => Response::Success(passwd_entries_to_passwds(r.into_inner().entries)),
Err(e) => {
error!("error when listing passwd: {}", e.code().description());
error!("error when listing passwd: {}", e.code());
super::grpc_status_to_nss_response(e)
}
}
Expand Down Expand Up @@ -81,11 +81,7 @@ fn get_entry_by_uid(uid: uid_t) -> Response<Passwd> {
match client.get_passwd_by_uid(req).await {
Ok(r) => Response::Success(passwd_entry_to_passwd(r.into_inner())),
Err(e) => {
error!(
"error when getting passwd by uid '{}': {}",
uid,
e.code().description()
);
error!("error when getting passwd by uid '{}': {}", uid, e.code());
super::grpc_status_to_nss_response(e)
}
}
Expand Down Expand Up @@ -122,7 +118,7 @@ fn get_entry_by_name(name: String) -> Response<Passwd> {
error!(
"error when getting passwd by name '{}': {}",
name,
e.code().description()
e.code()
);
super::grpc_status_to_nss_response(e)
}
Expand Down
8 changes: 2 additions & 6 deletions nss/src/shadow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn get_all_entries() -> Response<Vec<Shadow>> {
match client.get_shadow_entries(req).await {
Ok(r) => Response::Success(shadow_entries_to_shadows(r.into_inner().entries)),
Err(e) => {
error!("error when listing shadow: {}", e.code().description());
error!("error when listing shadow: {}", e.code());
super::grpc_status_to_nss_response(e)
}
}
Expand Down Expand Up @@ -76,11 +76,7 @@ fn get_entry_by_name(name: String) -> Response<Shadow> {
match client.get_shadow_by_name(req).await {
Ok(r) => Response::Success(shadow_entry_to_shadow(r.into_inner())),
Err(e) => {
error!(
"error when getting shadow by name '{}': {}",
name,
e.code().description()
);
error!("error when getting shadow by name '{}': {}", name, e.code());
super::grpc_status_to_nss_response(e)
}
}
Expand Down

0 comments on commit 314ccc6

Please sign in to comment.