diff --git a/client/src/main.rs b/client/src/main.rs index 8ef5b24..a61f4a2 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -1,10 +1,10 @@ // client/src/main.rs use client::run_ui; use dotenvy::dotenv; -use std::error::Error; +use anyhow::{anyhow, Result}; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<()> { dotenv().ok(); run_ui().await } diff --git a/client/src/modes/highlight/highlight.rs b/client/src/modes/highlight/highlight.rs index f4113b8..00e66b1 100644 --- a/client/src/modes/highlight/highlight.rs +++ b/client/src/modes/highlight/highlight.rs @@ -9,8 +9,9 @@ use crate::state::pages::auth::{LoginState, RegisterState}; use crate::state::pages::add_table::AddTableState; use crate::state::pages::form::FormState; use crate::modes::handlers::event::EventOutcome; -use crate::modes::read_only; // Import the ReadOnly handler +use crate::modes::read_only; use crossterm::event::KeyEvent; +use anyhow::{anyhow, Result}; /// Handles events when in Highlight mode. /// Currently, it mostly delegates to the read_only handler for movement. @@ -30,7 +31,7 @@ pub async fn handle_highlight_event( command_message: &mut String, edit_mode_cooldown: &mut bool, ideal_cursor_column: &mut usize, -) -> Result> { +) -> Result { // Delegate movement and other actions to the read_only handler // The rendering logic will use the highlight_anchor to draw the selection let (should_exit, message) = read_only::handle_read_only_event( diff --git a/client/src/tui/functions/form.rs b/client/src/tui/functions/form.rs index 3c20eb4..b99475b 100644 --- a/client/src/tui/functions/form.rs +++ b/client/src/tui/functions/form.rs @@ -2,6 +2,7 @@ use crate::state::pages::form::FormState; use crate::services::grpc_client::GrpcClient; use crate::state::pages::canvas_state::CanvasState; +use anyhow::{anyhow, Result}; pub async fn handle_action( action: &str, @@ -10,7 +11,7 @@ pub async fn handle_action( current_position: &mut u64, total_count: u64, ideal_cursor_column: &mut usize, -) -> Result> { +) -> Result { // TODO store unsaved changes without deleting form state values // First check for unsaved changes in both cases if form_state.has_unsaved_changes() { @@ -84,6 +85,7 @@ pub async fn handle_action( Ok("Already at last entry".into()) } } - _ => Err("Unknown form action".into()) + _ => Err(anyhow!("Unknown form action: {}", action)) + } } diff --git a/client/src/tui/functions/login.rs b/client/src/tui/functions/login.rs index 8a2bbbc..b43be96 100644 --- a/client/src/tui/functions/login.rs +++ b/client/src/tui/functions/login.rs @@ -1,6 +1,8 @@ // src/tui/functions/login.rs -pub async fn handle_action(action: &str,) -> Result> { +use anyhow::{anyhow, Result}; + +pub async fn handle_action(action: &str,) -> Result { match action { "previous_entry" => { Ok("Previous entry at tui/functions/login.rs not implemented".into()) @@ -8,6 +10,6 @@ pub async fn handle_action(action: &str,) -> Result { Ok("Next entry at tui/functions/login.rs not implemented".into()) } - _ => Err("Unknown login action".into()) + _ => Err(anyhow!("Unknown login action: {}", action)) } }