{finger,ruptime,rwho}: render nicer varlink errors for users

This commit is contained in:
2026-06-24 12:50:19 +09:00
parent 21945c73ab
commit 1bfc330000
3 changed files with 42 additions and 6 deletions
+12 -2
View File
@@ -5,7 +5,7 @@ use roowho2_lib::{
proto::finger_protocol::FingerResponseUserEntry, proto::finger_protocol::FingerResponseUserEntry,
server::{ server::{
fingerd::{FingerRequestInfo, FingerRequestNetworking}, fingerd::{FingerRequestInfo, FingerRequestNetworking},
varlink_api::VarlinkFingerClientProxy, varlink_api::{VarlinkFingerClientError, VarlinkFingerClientProxy},
}, },
}; };
@@ -196,7 +196,17 @@ async fn main() -> anyhow::Result<()> {
) )
.await .await
.context("Failed to send finger request")? .context("Failed to send finger request")?
.map_err(|e| anyhow::anyhow!("Server returned an error for finger request: {:?}", e))?; .map_err(|e| match e {
VarlinkFingerClientError::Disabled => {
anyhow::anyhow!("The fingerd service is disabled on the server")
}
VarlinkFingerClientError::TimedOut => {
anyhow::anyhow!("The fingerd service timed out while processing the request")
}
VarlinkFingerClientError::InvalidRequest => {
anyhow::anyhow!("The fingerd service could not process the request, please check the logs or report the error to your system administrators")
}
})?;
if args.json { if args.json {
println!("{}", serde_json::to_string_pretty(&reply).unwrap()); println!("{}", serde_json::to_string_pretty(&reply).unwrap());
+15 -2
View File
@@ -3,7 +3,10 @@ use chrono::{Duration, Utc};
use clap::{CommandFactory, Parser}; use clap::{CommandFactory, Parser};
use clap_complete::{Shell, generate}; use clap_complete::{Shell, generate};
use roowho2_lib::{proto::WhodStatusUpdate, server::varlink_api::VarlinkRwhodClientProxy}; use roowho2_lib::{
proto::WhodStatusUpdate,
server::varlink_api::{VarlinkRwhodClientError, VarlinkRwhodClientProxy},
};
/// Show host status of local machines. /// Show host status of local machines.
/// ///
@@ -70,7 +73,17 @@ async fn main() -> anyhow::Result<()> {
.ruptime(args.all) .ruptime(args.all)
.await .await
.context("Failed to send rwho request")? .context("Failed to send rwho request")?
.map_err(|e| anyhow::anyhow!("Server returned an error for rwho request: {:?}", e))?; .map_err(|e| match e {
VarlinkRwhodClientError::Disabled => {
anyhow::anyhow!("The rwhod service is disabled on the server")
}
VarlinkRwhodClientError::TimedOut => {
anyhow::anyhow!("The rwhod service timed out while processing the request")
}
VarlinkRwhodClientError::InvalidRequest => {
anyhow::anyhow!("The rwhod service could not process the request, please check the logs or report the error to your system administrators")
}
})?;
sort_entries(&mut reply, args.load, args.time, args.users, args.reverse); sort_entries(&mut reply, args.load, args.time, args.users, args.reverse);
+15 -2
View File
@@ -1,7 +1,10 @@
use anyhow::Context; use anyhow::Context;
use clap::{CommandFactory, Parser}; use clap::{CommandFactory, Parser};
use clap_complete::{Shell, generate}; use clap_complete::{Shell, generate};
use roowho2_lib::{proto::WhodUserEntry, server::varlink_api::VarlinkRwhodClientProxy}; use roowho2_lib::{
proto::WhodUserEntry,
server::varlink_api::{VarlinkRwhodClientError, VarlinkRwhodClientProxy},
};
/// Check who is logged in on local machines. /// Check who is logged in on local machines.
/// ///
@@ -50,7 +53,17 @@ async fn main() -> anyhow::Result<()> {
.rwho(args.all) .rwho(args.all)
.await .await
.context("Failed to send rwho request")? .context("Failed to send rwho request")?
.map_err(|e| anyhow::anyhow!("Server returned an error for rwho request: {:?}", e))?; .map_err(|e| match e {
VarlinkRwhodClientError::Disabled => {
anyhow::anyhow!("The rwhod service is disabled on the server")
}
VarlinkRwhodClientError::TimedOut => {
anyhow::anyhow!("The rwhod service timed out while processing the request")
}
VarlinkRwhodClientError::InvalidRequest => {
anyhow::anyhow!("The rwhod service could not process the request, please check the logs or report the error to your system administrators")
}
})?;
reply.sort_by(|(host, user), (host2, user2)| { reply.sort_by(|(host, user), (host2, user2)| {
user.user_id user.user_id