anyhow used

This commit is contained in:
filipriec
2025-04-18 19:04:05 +02:00
parent 09ccad2bd4
commit 5a029283a1
12 changed files with 69 additions and 74 deletions

View File

@@ -8,7 +8,7 @@ use crate::ui::handlers::rat_state::UiStateHandler;
use crate::ui::handlers::context::UiContext;
use crate::ui::handlers::context::DialogPurpose;
use crate::functions::common::buffer;
use std::error::Error;
use anyhow::{Context, Result};
use crate::tui::{
terminal::core::TerminalCore,
functions::{
@@ -68,7 +68,7 @@ pub struct EventHandler {
}
impl EventHandler {
pub async fn new(login_result_sender: mpsc::Sender<LoginResult>) -> Result<Self, Box<dyn Error + Send + Sync>> {
pub async fn new(login_result_sender: mpsc::Sender<LoginResult>) -> Result<Self> {
Ok(EventHandler {
command_mode: false,
command_input: String::new(),
@@ -100,7 +100,7 @@ impl EventHandler {
app_state: &mut AppState,
total_count: u64,
current_position: &mut u64,
) -> Result<EventOutcome, Box<dyn std::error::Error>> {
) -> Result<EventOutcome> {
let current_mode = ModeManager::derive_mode(app_state, self);
app_state.update_mode(current_mode);
@@ -257,7 +257,9 @@ impl EventHandler {
spawn(async move {
let login_outcome = match AuthClient::new().await {
Ok(mut auth_client) => {
match auth_client.login(username, password).await {
match auth_client.login(username.clone(), password).await
.with_context(|| format!("Spawned login task failed for identifier: {}", username))
{
Ok(response) => login::LoginResult::Success(response),
Err(e) => login::LoginResult::Failure(format!("{}", e)),
}