{finger,ruptime,rwho}: render nicer varlink errors for users
This commit is contained in:
+12
-2
@@ -5,7 +5,7 @@ use roowho2_lib::{
|
||||
proto::finger_protocol::FingerResponseUserEntry,
|
||||
server::{
|
||||
fingerd::{FingerRequestInfo, FingerRequestNetworking},
|
||||
varlink_api::VarlinkFingerClientProxy,
|
||||
varlink_api::{VarlinkFingerClientError, VarlinkFingerClientProxy},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -196,7 +196,17 @@ async fn main() -> anyhow::Result<()> {
|
||||
)
|
||||
.await
|
||||
.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 {
|
||||
println!("{}", serde_json::to_string_pretty(&reply).unwrap());
|
||||
|
||||
+15
-2
@@ -3,7 +3,10 @@ use chrono::{Duration, Utc};
|
||||
use clap::{CommandFactory, Parser};
|
||||
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.
|
||||
///
|
||||
@@ -70,7 +73,17 @@ async fn main() -> anyhow::Result<()> {
|
||||
.ruptime(args.all)
|
||||
.await
|
||||
.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);
|
||||
|
||||
|
||||
+15
-2
@@ -1,7 +1,10 @@
|
||||
use anyhow::Context;
|
||||
use clap::{CommandFactory, Parser};
|
||||
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.
|
||||
///
|
||||
@@ -50,7 +53,17 @@ async fn main() -> anyhow::Result<()> {
|
||||
.rwho(args.all)
|
||||
.await
|
||||
.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)| {
|
||||
user.user_id
|
||||
|
||||
Reference in New Issue
Block a user