diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-04-04 16:08:06 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-04-04 16:08:06 +0200 |
commit | 65d6489de1368d80f4968718ba022c4216d0df92 (patch) | |
tree | d606495a34f5c0e2345bbb57e11fb0ba4bf92434 | |
parent | feat(pkgs/tskm): Support listing the open tabs in a project (diff) | |
download | nixos-config-65d6489de1368d80f4968718ba022c4216d0df92.zip |
fix(pkgs/tskm): Add context to some errors
-rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/open/handle.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs index 08bd1de4..dc0d165d 100644 --- a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs @@ -8,7 +8,7 @@ use crate::{cli::OpenCommand, rofi, task}; pub fn handle(command: OpenCommand) -> Result<()> { match command { OpenCommand::Review => { - for project in task::Project::all()? { + for project in task::Project::all().context("Failed to get all project files")? { if project.is_touched() { info!("Reviewing project: '{}'", project.to_project_display()); open_in_browser(project).with_context(|| { @@ -29,14 +29,18 @@ pub fn handle(command: OpenCommand) -> Result<()> { OpenCommand::Project { project } => { let project = if let Some(p) = project { p - } else if let Some(p) = task::Project::get_current()? { + } else if let Some(p) = + task::Project::get_current().context("Failed to get currently focused project")? + { p } else { bail!("You need to either supply a project or have a project active!"); }; project.touch().context("Failed to touch project")?; - open_in_browser(&project).context("Failed to open project")?; + open_in_browser(&project).with_context(|| { + format!("Failed to open project: {}", project.to_project_display()) + })?; } OpenCommand::Select => { let selected_project: task::Project = task::Project::from_project_string( @@ -145,7 +149,8 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> { "Starting task {} -> tracking", selected_project.to_project_display() ); - task.start()?; + task.start() + .with_context(|| format!("Failed to start task {task}"))?; } tracking_task }; @@ -164,16 +169,20 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> { } if let Some(task) = tracking_task { - task.stop()?; + task.stop() + .with_context(|| format!("Failed to stop task {task}"))?; } if let Some(task) = old_task { - task.start()?; + task.start() + .with_context(|| format!("Failed to start task {task}"))?; } if let Some(project) = old_project { - project.activate()?; + project.activate().with_context(|| { + format!("Failed to active project {}", project.to_project_display()) + })?; } else { - task::Project::clear()?; + task::Project::clear().context("Failed to clear currently focused project")?; } Ok(()) |